1 diff -ur samba-3.0.25.orig/source/param/loadparm.c samba-3.0.25/source/param/loadparm.c
2 --- samba-3.0.25.orig/source/param/loadparm.c 2007-04-21 03:48:07.000000000 +0200
3 +++ samba-3.0.25/source/param/loadparm.c 2007-05-15 09:06:42.000000000 +0200
6 char *szVetoOplockFiles;
13 NULL, /* szHideFiles */
14 NULL, /* szVetoOplockFiles */
16 + NULL, /* location */
17 NULL, /* force user */
18 NULL, /* force group */
21 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
22 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
23 FN_LOCAL_STRING(lp_comment, comment)
24 +FN_LOCAL_STRING(lp_location, location)
25 FN_LOCAL_STRING(lp_force_user, force_user)
26 FN_LOCAL_STRING(lp_force_group, force_group)
27 FN_LOCAL_LIST(lp_readlist, readlist)
29 Auto-load one printer.
30 ***************************************************************************/
32 -void lp_add_one_printer(char *name, char *comment)
33 +void lp_add_one_printer(char *name, char *comment, char *location)
35 int printers = lp_servicenumber(PRINTERS_NAME);
38 lp_add_printer(name, printers);
39 if ((i = lp_servicenumber(name)) >= 0) {
40 string_set(&ServicePtrs[i]->comment, comment);
41 + string_set(&ServicePtrs[i]->location, location);
42 ServicePtrs[i]->autoloaded = True;
45 diff -ur samba-3.0.25.orig/source/printing/nt_printing.c samba-3.0.25/source/printing/nt_printing.c
46 --- samba-3.0.25.orig/source/printing/nt_printing.c 2007-05-11 00:09:34.000000000 +0200
47 +++ samba-3.0.25/source/printing/nt_printing.c 2007-05-15 13:58:02.000000000 +0200
48 @@ -3291,7 +3291,39 @@
52 - ads_kdestroy("MEMORY:prtpub_cache");
56 +WERROR update_published_printer(NT_PRINTER_INFO_LEVEL *printer)
59 + ADS_STRUCT *ads = NULL;
61 + if (!(printer->info_2->attributes & PRINTER_ATTRIBUTE_PUBLISHED))
64 + ads = ads_init(NULL, NULL, NULL);
66 + DEBUG(3, ("ads_init() failed\n"));
67 + return WERR_SERVER_UNAVAILABLE;
69 + setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
70 + SAFE_FREE(ads->auth.password);
71 + ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
74 + /* ads_connect() will find the DC for us */
75 + ads_rc = ads_connect(ads);
76 + if (!ADS_ERR_OK(ads_rc)) {
77 + DEBUG(3, ("ads_connect failed: %s\n", ads_errstr(ads_rc)));
79 + ads_kdestroy("MEMORY:prtpub_cache");
80 + return WERR_ACCESS_DENIED;
83 + nt_printer_publish_ads(ads, printer);
90 fstrcpy(info->printprocessor, "winprint");
91 fstrcpy(info->datatype, "RAW");
94 +#ifdef HAVE_CUPS_BLOAT
95 if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {
96 /* Pull the location and comment strings from cups if we don't
100 fstrcpy(info->printername, printername);
103 +#ifdef HAVE_CUPS_BLOAT
104 if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {
105 /* Pull the location and comment strings from cups if we don't
107 diff -ur samba-3.0.25.orig/source/printing/pcap.c samba-3.0.25/source/printing/pcap.c
108 --- samba-3.0.25.orig/source/printing/pcap.c 2005-10-18 04:44:57.000000000 +0200
109 +++ samba-3.0.25/source/printing/pcap.c 2007-05-15 09:06:42.000000000 +0200
111 typedef struct pcap_cache {
115 struct pcap_cache *next;
118 static pcap_cache_t *pcap_cache = NULL;
120 -BOOL pcap_cache_add(const char *name, const char *comment)
121 +BOOL pcap_cache_add(const char *name, const char *comment, const char *location)
127 p->name = SMB_STRDUP(name);
128 p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL;
129 + p->location = (location && *location) ? SMB_STRDUP(location) : NULL;
131 p->next = pcap_cache;
136 SAFE_FREE(p->comment);
137 + SAFE_FREE(p->location);
142 if (printing == PRINT_LPRNG && *name == '.')
145 - if (*name && !pcap_cache_add(name, comment)) {
146 + if (*name && !pcap_cache_add(name, comment, NULL)) {
150 @@ -252,12 +255,12 @@
152 XXX: I'm not sure if this comment still applies.. Anyone? -Rob
153 ***************************************************************************/
154 -void pcap_printer_fn(void (*fn)(char *, char *))
155 +void pcap_printer_fn(void (*fn)(char *, char *, char *))
159 for (p = pcap_cache; p != NULL; p = p->next)
160 - fn(p->name, p->comment);
161 + fn(p->name, p->comment, p->location);
165 diff -ur samba-3.0.25.orig/source/printing/print_aix.c samba-3.0.25/source/printing/print_aix.c
166 --- samba-3.0.25.orig/source/printing/print_aix.c 2005-02-25 18:59:28.000000000 +0100
167 +++ samba-3.0.25/source/printing/print_aix.c 2007-05-15 09:06:42.000000000 +0200
169 /* name is found without stanza device */
170 /* probably a good printer ??? */
172 - if (!pcap_cache_add(name, NULL)) {
173 + if (!pcap_cache_add(name, NULL, NULL)) {
178 } else if (strstr_m(line, "device")) {
179 /* it's a good virtual printer */
181 - if (!pcap_cache_add(name, NULL)) {
182 + if (!pcap_cache_add(name, NULL, NULL)) {
186 diff -ur samba-3.0.25.orig/source/printing/print_cups.c samba-3.0.25/source/printing/print_cups.c
187 --- samba-3.0.25.orig/source/printing/print_cups.c 2007-04-09 19:30:57.000000000 +0200
188 +++ samba-3.0.25/source/printing/print_cups.c 2007-05-15 09:06:42.000000000 +0200
190 ipp_attribute_t *attr; /* Current attribute */
191 cups_lang_t *language = NULL; /* Default language */
192 char *name, /* printer-name attribute */
193 - *info; /* printer-info attribute */
194 + *info, /* printer-info attribute */
195 + *location; /* printer-location attribute */
196 static const char *requested[] =/* Requested attributes */
210 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
211 if (strcmp(attr->name, "printer-name") == 0 &&
213 attr->value_tag == IPP_TAG_TEXT)
214 info = attr->values[0].string.text;
216 + if (strcmp(attr->name, "printer-location") == 0 &&
217 + attr->value_tag == IPP_TAG_TEXT)
218 + location = attr->values[0].string.text;
227 - if (!pcap_cache_add(name, info)) {
228 + if (!pcap_cache_add(name, info, location)) {
238 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
239 if (strcmp(attr->name, "printer-name") == 0 &&
241 attr->value_tag == IPP_TAG_TEXT)
242 info = attr->values[0].string.text;
244 + if (strcmp(attr->name, "printer-location") == 0 &&
245 + attr->value_tag == IPP_TAG_TEXT)
246 + info = attr->values[0].string.text;
255 - if (!pcap_cache_add(name, info)) {
256 + if (!pcap_cache_add(name, info, location)) {
260 diff -ur samba-3.0.25.orig/source/printing/print_iprint.c samba-3.0.25/source/printing/print_iprint.c
261 --- samba-3.0.25.orig/source/printing/print_iprint.c 2007-03-01 05:54:09.000000000 +0100
262 +++ samba-3.0.25/source/printing/print_iprint.c 2007-05-15 09:06:42.000000000 +0200
266 if (name != NULL && !secure && smb_enabled)
267 - pcap_cache_add(name, info);
268 + pcap_cache_add(name, info, NULL);
272 diff -ur samba-3.0.25.orig/source/printing/print_svid.c samba-3.0.25/source/printing/print_svid.c
273 --- samba-3.0.25.orig/source/printing/print_svid.c 2005-12-02 20:21:45.000000000 +0100
274 +++ samba-3.0.25/source/printing/print_svid.c 2007-05-15 09:06:42.000000000 +0200
278 /* add it to the cache */
279 - if (!pcap_cache_add(name, NULL)) {
280 + if (!pcap_cache_add(name, NULL, NULL)) {
281 file_lines_free(lines);
284 diff -ur samba-3.0.25.orig/source/rpcclient/cmd_spoolss.c samba-3.0.25/source/rpcclient/cmd_spoolss.c
285 --- samba-3.0.25.orig/source/rpcclient/cmd_spoolss.c 2007-05-11 00:09:33.000000000 +0200
286 +++ samba-3.0.25/source/rpcclient/cmd_spoolss.c 2007-05-15 10:38:35.000000000 +0200
287 @@ -476,19 +476,23 @@
295 - if (argc == 1 || argc > 3) {
296 - printf("Usage: %s printername comment\n", argv[0]);
297 + if (argc == 1 || argc > 4) {
298 + printf("Usage: %s printername comment [location]\n", argv[0]);
303 /* Open a printer handle */
306 fstrcpy(comment, argv[2]);
310 + fstrcpy(location, argv[3]);
313 slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
314 strupper_m(servername);
315 slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
316 @@ -513,12 +517,15 @@
318 /* Modify the comment. */
319 init_unistr(&ctr.printers_2->comment, comment);
320 + /* Modify the location. */
322 + init_unistr(&ctr.printers_2->location, location);
323 ctr.printers_2->devmode = NULL;
324 ctr.printers_2->secdesc = NULL;
326 result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0);
327 if (W_ERROR_IS_OK(result))
328 - printf("Success in setting comment.\n");
329 + printf("Success in setting comment%s.\n", argc==4?" and location":"");
333 diff -ur samba-3.0.25.orig/source/rpc_server/srv_spoolss_nt.c samba-3.0.25/source/rpc_server/srv_spoolss_nt.c
334 --- samba-3.0.25.orig/source/rpc_server/srv_spoolss_nt.c 2007-05-11 00:09:35.000000000 +0200
335 +++ samba-3.0.25/source/rpc_server/srv_spoolss_nt.c 2007-05-15 11:44:07.000000000 +0200
336 @@ -2901,7 +2901,10 @@
340 - len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE);
341 + if (*printer->info_2->location == '\0')
342 + len = rpcstr_push(temp, lp_location(snum), sizeof(temp)-2, STR_TERMINATE);
344 + len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE);
346 data->notify_data.data.length = len;
348 @@ -4204,8 +4207,10 @@
349 init_unistr(&printer->comment, lp_comment(snum)); /* comment */
351 init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
353 - init_unistr(&printer->location, ntprinter->info_2->location); /* location */
354 + if (*ntprinter->info_2->location == '\0')
355 + init_unistr(&printer->location, lp_location(snum)); /* location */
357 + init_unistr(&printer->location, ntprinter->info_2->location); /* location */
358 init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */
359 init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */
360 init_unistr(&printer->datatype, ntprinter->info_2->datatype); /* datatype */
361 @@ -6341,6 +6346,13 @@
362 /* Update printer info */
363 result = mod_a_printer(printer, 2);
365 + /* Update ADS entry */
366 + if (W_ERROR_IS_OK(result) && lp_security() == SEC_ADS &&
367 + ( !strequal(printer->info_2->comment, old_printer->info_2->comment)
368 + || !strequal(printer->info_2->location, old_printer->info_2->location)
369 + || !strequal(printer->info_2->printername, old_printer->info_2->printername))) {
370 + update_published_printer (printer);
373 free_a_printer(&printer, 2);
374 free_a_printer(&old_printer, 2);