+++ /dev/null
-diff -ur samba-3.2.7.orig/source/param/loadparm.c samba-3.2.7/source/param/loadparm.c
---- samba-3.2.7.orig/source/param/loadparm.c 2009-01-19 10:58:56.000000000 +0100
-+++ samba-3.2.7/source/param/loadparm.c 2009-01-19 11:01:03.000000000 +0100
-@@ -382,6 +382,7 @@
- char *szHideFiles;
- char *szVetoOplockFiles;
- char *comment;
-+ char *location;
- char *force_user;
- char *force_group;
- char **readlist;
-@@ -525,6 +526,7 @@
- NULL, /* szHideFiles */
- NULL, /* szVetoOplockFiles */
- NULL, /* comment */
-+ NULL, /* location */
- NULL, /* force user */
- NULL, /* force group */
- NULL, /* readlist */
-@@ -5227,6 +5229,7 @@
- FN_LOCAL_STRING(lp_magicscript, szMagicScript)
- FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
- FN_LOCAL_STRING(lp_comment, comment)
-+FN_LOCAL_STRING(lp_location, location)
- FN_LOCAL_STRING(lp_force_user, force_user)
- FN_LOCAL_STRING(lp_force_group, force_group)
- FN_LOCAL_LIST(lp_readlist, readlist)
-@@ -7789,7 +7792,7 @@
- Auto-load one printer.
- ***************************************************************************/
-
--void lp_add_one_printer(const char *name, const char *comment, void *pdata)
-+void lp_add_one_printer(const char *name, const char *comment, const char *location, void *pdata)
- {
- int printers = lp_servicenumber(PRINTERS_NAME);
- int i;
-@@ -7798,6 +7801,7 @@
- lp_add_printer(name, printers);
- if ((i = lp_servicenumber(name)) >= 0) {
- string_set(&ServicePtrs[i]->comment, comment);
-+ string_set(&ServicePtrs[i]->location, location);
- ServicePtrs[i]->autoloaded = True;
- }
- }
-diff -ur samba-3.2.7.orig/source/printing/nt_printing.c samba-3.2.7/source/printing/nt_printing.c
---- samba-3.2.7.orig/source/printing/nt_printing.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/printing/nt_printing.c 2009-01-19 11:00:06.000000000 +0100
-@@ -3499,7 +3499,39 @@
- }
-
- ads_destroy(&ads);
-- ads_kdestroy("MEMORY:prtpub_cache");
-+ return WERR_OK;
-+}
-+
-+WERROR update_published_printer(NT_PRINTER_INFO_LEVEL *printer)
-+{
-+ ADS_STATUS ads_rc;
-+ ADS_STRUCT *ads = NULL;
-+
-+ if (!(printer->info_2->attributes & PRINTER_ATTRIBUTE_PUBLISHED))
-+ return WERR_OK;
-+
-+ ads = ads_init(NULL, NULL, NULL);
-+ if (!ads) {
-+ DEBUG(3, ("ads_init() failed\n"));
-+ return WERR_SERVER_UNAVAILABLE;
-+ }
-+ setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
-+ SAFE_FREE(ads->auth.password);
-+ ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
-+ NULL, NULL);
-+
-+ /* ads_connect() will find the DC for us */
-+ ads_rc = ads_connect(ads);
-+ if (!ADS_ERR_OK(ads_rc)) {
-+ DEBUG(3, ("ads_connect failed: %s\n", ads_errstr(ads_rc)));
-+ ads_destroy(&ads);
-+ ads_kdestroy("MEMORY:prtpub_cache");
-+ return WERR_ACCESS_DENIED;
-+ }
-+
-+ nt_printer_publish_ads(ads, printer);
-+
-+ ads_destroy(&ads);
- return WERR_OK;
- }
-
-@@ -4014,7 +4046,7 @@
- fstrcpy(info->printprocessor, "winprint");
- fstrcpy(info->datatype, "RAW");
-
--#ifdef HAVE_CUPS
-+#ifdef HAVE_CUPS_BLOAT
- if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {
- /* Pull the location and comment strings from cups if we don't
- already have one */
-@@ -4129,7 +4161,7 @@
-
- fstrcpy(info->printername, printername);
-
--#ifdef HAVE_CUPS
-+#ifdef HAVE_CUPS_BLOAT
- if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {
- /* Pull the location and comment strings from cups if we don't
- already have one */
-diff -ur samba-3.2.7.orig/source/printing/pcap.c samba-3.2.7/source/printing/pcap.c
---- samba-3.2.7.orig/source/printing/pcap.c 2009-01-19 10:58:56.000000000 +0100
-+++ samba-3.2.7/source/printing/pcap.c 2009-01-19 11:12:09.000000000 +0100
-@@ -66,13 +66,14 @@
- struct pcap_cache {
- char *name;
- char *comment;
-+ char *location;
- struct pcap_cache *next;
- };
-
- /* The systemwide printcap cache. */
- static struct pcap_cache *pcap_cache = NULL;
-
--bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment)
-+bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment, const char *location)
- {
- struct pcap_cache *p;
-
-@@ -81,9 +82,10 @@
-
- p->name = SMB_STRDUP(name);
- p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL;
-+ p->location = (location && *location) ? SMB_STRDUP(location) : NULL;
-
-- DEBUG(11,("pcap_cache_add_specific: Adding name %s info %s\n",
-- p->name, p->comment ? p->comment : ""));
-+ DEBUG(11,("pcap_cache_add_specific: Adding name %s info %s, location %s\n",
-+ p->name, p->comment ? p->comment : "", p->location ? p->location : ""));
-
- p->next = *ppcache;
- *ppcache = p;
-@@ -100,14 +102,15 @@
-
- SAFE_FREE(p->name);
- SAFE_FREE(p->comment);
-+ SAFE_FREE(p->location);
- SAFE_FREE(p);
- }
- *pp_cache = NULL;
- }
-
--bool pcap_cache_add(const char *name, const char *comment)
-+bool pcap_cache_add(const char *name, const char *comment, const char *location)
- {
-- return pcap_cache_add_specific(&pcap_cache, name, comment);
-+ return pcap_cache_add_specific(&pcap_cache, name, comment, location);
- }
-
- bool pcap_cache_loaded(void)
-@@ -121,7 +124,7 @@
-
- pcap_cache_destroy_specific(&pcap_cache);
- for (p = pcache; p; p = p->next) {
-- pcap_cache_add(p->name, p->comment);
-+ pcap_cache_add(p->name, p->comment, p->location);
- }
- }
-
-@@ -235,7 +238,7 @@
- if (printing == PRINT_LPRNG && *name == '.')
- continue;
-
-- if (*name && !pcap_cache_add(name, comment)) {
-+ if (*name && !pcap_cache_add(name, comment, NULL)) {
- x_fclose(pcap_file);
- goto done;
- }
-@@ -274,18 +277,18 @@
- ***************************************************************************/
-
- void pcap_printer_fn_specific(const struct pcap_cache *pc,
-- void (*fn)(const char *, const char *, void *),
-+ void (*fn)(const char *, const char *, const char *, void *),
- void *pdata)
- {
- const struct pcap_cache *p;
-
- for (p = pc; p != NULL; p = p->next)
-- fn(p->name, p->comment, pdata);
-+ fn(p->name, p->comment, p->location, pdata);
-
- return;
- }
-
--void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *pdata)
-+void pcap_printer_fn(void (*fn)(const char *, const char *, const char *, void *), void *pdata)
- {
- pcap_printer_fn_specific(pcap_cache, fn, pdata);
- }
-diff -ur samba-3.2.7.orig/source/printing/print_aix.c samba-3.2.7/source/printing/print_aix.c
---- samba-3.2.7.orig/source/printing/print_aix.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/printing/print_aix.c 2009-01-19 11:00:06.000000000 +0100
-@@ -84,7 +84,7 @@
- /* name is found without stanza device */
- /* probably a good printer ??? */
- iEtat = 0;
-- if (!pcap_cache_add(name, NULL)) {
-+ if (!pcap_cache_add(name, NULL, NULL)) {
- safe_free(line);
- x_fclose(pfile);
- TALLOC_FREE(ctx);
-@@ -99,7 +99,7 @@
- } else if (strstr_m(line, "device")) {
- /* it's a good virtual printer */
- iEtat = 0;
-- if (!pcap_cache_add(name, NULL)) {
-+ if (!pcap_cache_add(name, NULL, NULL)) {
- safe_free(line);
- x_fclose(pfile);
- TALLOC_FREE(ctx);
-diff -ur samba-3.2.7.orig/source/printing/print_cups.c samba-3.2.7/source/printing/print_cups.c
---- samba-3.2.7.orig/source/printing/print_cups.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/printing/print_cups.c 2009-01-19 11:27:29.000000000 +0100
-@@ -82,11 +82,12 @@
- return http;
- }
-
--static void send_pcap_info(const char *name, const char *info, void *pd)
-+static void send_pcap_info(const char *name, const char *info, const char *location, void *pd)
- {
- int fd = *(int *)pd;
- size_t namelen = name ? strlen(name)+1 : 0;
- size_t infolen = info ? strlen(info)+1 : 0;
-+ size_t locationlen = location ? strlen(location)+1 : 0;
-
- DEBUG(11,("send_pcap_info: writing namelen %u\n", (unsigned int)namelen));
- if (sys_write(fd, &namelen, sizeof(namelen)) != sizeof(namelen)) {
-@@ -100,6 +101,12 @@
- strerror(errno)));
- return;
- }
-+ DEBUG(11,("send_pcap_info: writing locationlen %u\n", (unsigned int)locationlen));
-+ if (sys_write(fd, &locationlen, sizeof(locationlen)) != sizeof(locationlen)) {
-+ DEBUG(10,("send_pcap_info: locationlen write failed %s\n",
-+ strerror(errno)));
-+ return;
-+ }
- if (namelen) {
- DEBUG(11,("send_pcap_info: writing name %s\n", name));
- if (sys_write(fd, name, namelen) != namelen) {
-@@ -116,6 +123,14 @@
- return;
- }
- }
-+ if (locationlen) {
-+ DEBUG(11,("send_pcap_info: writing location %s\n", location));
-+ if (sys_write(fd, location, locationlen) != locationlen) {
-+ DEBUG(10,("send_pcap_info: location write failed %s\n",
-+ strerror(errno)));
-+ return;
-+ }
-+ }
- }
-
- static bool cups_cache_reload_async(int fd)
-@@ -128,11 +143,13 @@
- ipp_attribute_t *attr; /* Current attribute */
- cups_lang_t *language = NULL; /* Default language */
- char *name, /* printer-name attribute */
-- *info; /* printer-info attribute */
-+ *info, /* printer-info attribute */
-+ *location; /* printer-location attribute */
- static const char *requested[] =/* Requested attributes */
- {
- "printer-name",
-- "printer-info"
-+ "printer-info",
-+ "printer-location"
- };
- bool ret = False;
-
-@@ -206,6 +223,7 @@
-
- name = NULL;
- info = NULL;
-+ location = NULL;
-
- while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
- if (strcmp(attr->name, "printer-name") == 0 &&
-@@ -222,6 +240,12 @@
- attr->values[0].string.text);
- }
-
-+ if (strcmp(attr->name, "printer-location") == 0 &&
-+ attr->value_tag == IPP_TAG_TEXT)
-+ pull_utf8_talloc(frame,
-+ &location,
-+ attr->values[0].string.text);
-+
- attr = attr->next;
- }
-
-@@ -232,7 +256,7 @@
- if (name == NULL)
- break;
-
-- if (!pcap_cache_add_specific(&tmp_pcap_cache, name, info)) {
-+ if (!pcap_cache_add_specific(&tmp_pcap_cache, name, info, location)) {
- goto out;
- }
- }
-@@ -292,6 +316,7 @@
-
- name = NULL;
- info = NULL;
-+ location = NULL;
-
- while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
- if (strcmp(attr->name, "printer-name") == 0 &&
-@@ -308,6 +333,12 @@
- attr->values[0].string.text);
- }
-
-+ if (strcmp(attr->name, "printer-location") == 0 &&
-+ attr->value_tag == IPP_TAG_TEXT)
-+ pull_utf8_talloc(frame,
-+ &location,
-+ attr->values[0].string.text);
-+
- attr = attr->next;
- }
-
-@@ -318,7 +349,7 @@
- if (name == NULL)
- break;
-
-- if (!pcap_cache_add_specific(&tmp_pcap_cache, name, info)) {
-+ if (!pcap_cache_add_specific(&tmp_pcap_cache, name, info, location)) {
- goto out;
- }
- }
-@@ -412,8 +443,8 @@
- "fd = %d\n", fd));
-
- while (1) {
-- char *name = NULL, *info = NULL;
-- size_t namelen = 0, infolen = 0;
-+ char *name = NULL, *info = NULL, *location = NULL;
-+ size_t namelen = 0, infolen = 0, locationlen = 0;
- ssize_t ret = -1;
-
- ret = sys_read(fd, &namelen, sizeof(namelen));
-@@ -444,6 +475,20 @@
- DEBUG(11,("cups_async_callback: read infolen %u\n",
- (unsigned int)infolen));
-
-+ ret = sys_read(fd, &locationlen, sizeof(locationlen));
-+ if (ret == 0) {
-+ /* EOF */
-+ break;
-+ }
-+ if (ret != sizeof(locationlen)) {
-+ DEBUG(10,("cups_async_callback: locationlen read failed %s\n",
-+ strerror(errno)));
-+ break;
-+ }
-+
-+ DEBUG(11,("cups_async_callback: read locationlen %u\n",
-+ (unsigned int)locationlen));
-+
- if (namelen) {
- name = TALLOC_ARRAY(frame, char, namelen);
- if (!name) {
-@@ -484,11 +529,32 @@
- } else {
- info = NULL;
- }
-+ if (locationlen) {
-+ location = TALLOC_ARRAY(frame, char, locationlen);
-+ if (!location) {
-+ break;
-+ }
-+ ret = sys_read(fd, location, locationlen);
-+ if (ret == 0) {
-+ /* EOF */
-+ break;
-+ }
-+ if (ret != locationlen) {
-+ DEBUG(10,("cups_async_callback: location read failed %s\n",
-+ strerror(errno)));
-+ break;
-+ }
-+ DEBUG(11,("cups_async_callback: read location %s\n",
-+ location));
-+ } else {
-+ location = NULL;
-+ }
-
- /* Add to our local pcap cache. */
-- pcap_cache_add_specific(&tmp_pcap_cache, name, info);
-+ pcap_cache_add_specific(&tmp_pcap_cache, name, info, location);
- TALLOC_FREE(name);
- TALLOC_FREE(info);
-+ TALLOC_FREE(location);
- }
-
- TALLOC_FREE(frame);
-diff -ur samba-3.2.7.orig/source/printing/print_iprint.c samba-3.2.7/source/printing/print_iprint.c
---- samba-3.2.7.orig/source/printing/print_iprint.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/printing/print_iprint.c 2009-01-19 11:00:06.000000000 +0100
-@@ -296,7 +296,7 @@
- */
-
- if (name != NULL && !secure && smb_enabled)
-- pcap_cache_add(name, info);
-+ pcap_cache_add(name, info, NULL);
- }
-
- out:
-diff -ur samba-3.2.7.orig/source/printing/print_svid.c samba-3.2.7/source/printing/print_svid.c
---- samba-3.2.7.orig/source/printing/print_svid.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/printing/print_svid.c 2009-01-19 11:00:06.000000000 +0100
-@@ -110,7 +110,7 @@
- *tmp = '\0';
-
- /* add it to the cache */
-- if (!pcap_cache_add(name, NULL)) {
-+ if (!pcap_cache_add(name, NULL, NULL)) {
- file_lines_free(lines);
- return False;
- }
-diff -ur samba-3.2.7.orig/source/rpcclient/cmd_spoolss.c samba-3.2.7/source/rpcclient/cmd_spoolss.c
---- samba-3.2.7.orig/source/rpcclient/cmd_spoolss.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/rpcclient/cmd_spoolss.c 2009-01-19 11:00:06.000000000 +0100
-@@ -475,19 +475,23 @@
- fstring printername,
- servername,
- user,
-- comment;
-+ comment,
-+ location;
-
-- if (argc == 1 || argc > 3) {
-- printf("Usage: %s printername comment\n", argv[0]);
-+ if (argc == 1 || argc > 4) {
-+ printf("Usage: %s printername comment [location]\n", argv[0]);
-
- return WERR_OK;
- }
-
- /* Open a printer handle */
-- if (argc == 3) {
-+ if (argc >= 3) {
- fstrcpy(comment, argv[2]);
- }
--
-+ if (argc == 4) {
-+ fstrcpy(location, argv[3]);
-+ }
-+
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
- strupper_m(servername);
- slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
-@@ -512,12 +516,15 @@
-
- /* Modify the comment. */
- init_unistr(&ctr.printers_2->comment, comment);
-+ /* Modify the location. */
-+ if (argc == 4)
-+ init_unistr(&ctr.printers_2->location, location);
- ctr.printers_2->devmode = NULL;
- ctr.printers_2->secdesc = NULL;
-
- result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0);
- if (W_ERROR_IS_OK(result))
-- printf("Success in setting comment.\n");
-+ printf("Success in setting comment%s.\n", argc==4?" and location":"");
-
- done:
- if (opened_hnd)
-diff -ur samba-3.2.7.orig/source/rpc_server/srv_spoolss_nt.c samba-3.2.7/source/rpc_server/srv_spoolss_nt.c
---- samba-3.2.7.orig/source/rpc_server/srv_spoolss_nt.c 2008-12-19 14:57:33.000000000 +0100
-+++ samba-3.2.7/source/rpc_server/srv_spoolss_nt.c 2009-01-19 11:00:06.000000000 +0100
-@@ -2934,7 +2934,10 @@
- smb_ucs2_t *temp = NULL;
- uint32 len;
-
-- len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->location);
-+ if (*printer->info_2->location == '\0')
-+ len = rpcstr_push_talloc(mem_ctx, &temp, lp_location(snum));
-+ else
-+ len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->location);
- if (len == (uint32)-1) {
- len = 0;
- }
-@@ -4213,8 +4216,10 @@
- init_unistr(&printer->comment, lp_comment(snum)); /* comment */
- else
- init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
--
-- init_unistr(&printer->location, ntprinter->info_2->location); /* location */
-+ if (*ntprinter->info_2->location == '\0')
-+ init_unistr(&printer->location, lp_location(snum)); /* location */
-+ else
-+ init_unistr(&printer->location, ntprinter->info_2->location); /* location */
- init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */
- init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */
- init_unistr(&printer->datatype, ntprinter->info_2->datatype); /* datatype */
-@@ -6484,6 +6489,13 @@
- /* Update printer info */
- result = mod_a_printer(printer, 2);
-
-+ /* Update ADS entry */
-+ if (W_ERROR_IS_OK(result) && lp_security() == SEC_ADS &&
-+ ( !strequal(printer->info_2->comment, old_printer->info_2->comment)
-+ || !strequal(printer->info_2->location, old_printer->info_2->location)
-+ || !strequal(printer->info_2->printername, old_printer->info_2->printername))) {
-+ update_published_printer (printer);
-+ }
- done:
- free_a_printer(&printer, 2);
- free_a_printer(&old_printer, 2);