[SCM] Samba Shared Repository - branch v3-6-test updated

Günther Deschner gd at samba.org
Mon May 16 11:10:15 MDT 2011


The branch, v3-6-test has been updated
       via  3275986 s3-printing: remove cups_pull_comment_location from header file
       via  07652a7 s3-printing: Remove obsolete and unused cups_pull_comment_location().
       via  3006de1 s3-spoolss: Get the printer location from cups.
       via  090b5b0 s3-printing: Get the location info from cups.
      from  68936f4 s3-includes: no need to globally include libads/ads_status.h.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 327598652b106e9a09bfab5d35d3534c9093356a
Author: David Disseldorp <ddiss at suse.de>
Date:   Mon May 16 13:26:41 2011 +0200

    s3-printing: remove cups_pull_comment_location from header file
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    
    Autobuild-User: Günther Deschner <gd at samba.org>
    Autobuild-Date: Mon May 16 16:03:57 CEST 2011 on sn-devel-104
    (cherry picked from commit 6bfe488f29a9df26f3d6dbc4166200ea286536c1)

commit 07652a7c7e55bf1e4acd3e4dd97880b8aba01596
Author: Andreas Schneider <asn at samba.org>
Date:   Fri May 13 10:57:33 2011 +0200

    s3-printing: Remove obsolete and unused cups_pull_comment_location().
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 01bc556d03a592e1f3c848d71b2e72a7cb74706f)

commit 3006de14fb3b68d2be0bae65023e9ca8e4d11ff6
Author: Andreas Schneider <asn at samba.org>
Date:   Fri May 13 10:28:20 2011 +0200

    s3-spoolss: Get the printer location from cups.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit da1fa201040b2dab89fdc99663155a1c79ad4de9)

commit 090b5b03d2c52c4fa4eeaecc4b4b815bd1948177
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 13 10:02:42 2011 +0200

    s3-printing: Get the location info from cups.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 854467851da48e02dcd8f869cb031c8943707017)

-----------------------------------------------------------------------

Summary of changes:
 librpc/idl/printcap.idl                     |    1 +
 source3/include/proto.h                     |    3 +-
 source3/param/loadparm.c                    |    3 +-
 source3/printing/pcap.c                     |   24 ++--
 source3/printing/pcap.h                     |   12 +--
 source3/printing/print_aix.c                |    4 +-
 source3/printing/print_cups.c               |  175 +++------------------------
 source3/printing/print_iprint.c             |    2 +-
 source3/printing/print_standard.c           |    2 +-
 source3/printing/print_svid.c               |    2 +-
 source3/printing/printer_list.c             |   42 +++++--
 source3/printing/printer_list.h             |    8 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c |   35 +++++-
 13 files changed, 118 insertions(+), 195 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/idl/printcap.idl b/librpc/idl/printcap.idl
index 5ab380c..d9c34f3 100644
--- a/librpc/idl/printcap.idl
+++ b/librpc/idl/printcap.idl
@@ -7,6 +7,7 @@ interface printcap
 	typedef struct {
 		[charset(UTF8),string] uint8 *name;
 		[charset(UTF8),string] uint8 *info;
+		[charset(UTF8),string] uint8 *location;
 	} pcap_printer;
 
 	typedef [public] struct {
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d25764b..d072502 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1740,7 +1740,8 @@ bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
 struct parm_struct *lp_get_parameter(const char *param_name);
 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
 bool lp_snum_ok(int iService);
-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);
 bool lp_loaded(void);
 void lp_killunused(bool (*snumused) (int));
 void lp_kill_all_services(void);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index ca54717..73406c1 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -8610,7 +8610,8 @@ static void lp_add_auto_services(char *str)
  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;
diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index 7208f4b..62db4f5 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -43,10 +43,11 @@
 struct pcap_cache {
 	char *name;
 	char *comment;
+	char *location;
 	struct pcap_cache *next;
 };
 
-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;
 
@@ -55,9 +56,11 @@ bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, cons
 
 	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;
@@ -74,17 +77,18 @@ void pcap_cache_destroy_specific(struct pcap_cache **pp_cache)
 
 		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)
 {
 	NTSTATUS status;
 	time_t t = time_mono(NULL);
 
-	status = printer_list_set_printer(talloc_tos(), name, comment, t);
+	status = printer_list_set_printer(talloc_tos(), name, comment, location, t);
 	return NT_STATUS_IS_OK(status);
 }
 
@@ -109,7 +113,7 @@ bool pcap_cache_replace(const struct pcap_cache *pcache)
 	}
 
 	for (p = pcache; p; p = p->next) {
-		pcap_cache_add(p->name, p->comment);
+		pcap_cache_add(p->name, p->comment, p->location);
 	}
 
 	status = printer_list_clean_old();
@@ -205,7 +209,7 @@ bool pcap_printername_ok(const char *printername)
 {
 	NTSTATUS status;
 
-	status = printer_list_get_printer(talloc_tos(), printername, NULL, 0);
+	status = printer_list_get_printer(talloc_tos(), printername, NULL, NULL, 0);
 	return NT_STATUS_IS_OK(status);
 }
 
@@ -214,18 +218,18 @@ run a function on each printer name in the printcap file.
 ***************************************************************************/
 
 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)
 {
 	NTSTATUS status;
 
diff --git a/source3/printing/pcap.h b/source3/printing/pcap.h
index e24142e..63497fd 100644
--- a/source3/printing/pcap.h
+++ b/source3/printing/pcap.h
@@ -20,13 +20,13 @@ struct pcap_cache;
 
 /* The following definitions come from printing/pcap.c  */
 
-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);
 void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
-bool pcap_cache_add(const char *name, const char *comment);
+bool pcap_cache_add(const char *name, const char *comment, const char *location);
 bool pcap_cache_loaded(void);
 bool pcap_cache_replace(const struct pcap_cache *cache);
-void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
-void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
+void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, const char *, void *), void *);
+void pcap_printer_fn(void (*fn)(const char *, const char *, const char *, void *), void *);
 
 void pcap_cache_reload(struct tevent_context *ev,
 		       struct messaging_context *msg_ctx,
@@ -44,10 +44,6 @@ bool cups_cache_reload(struct tevent_context *ev,
 		       struct messaging_context *msg_ctx,
 		       void (*post_cache_fill_fn)(struct tevent_context *,
 						  struct messaging_context *));
-bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
-				const char *printername,
-				char **comment,
-				char **location);
 
 /* The following definitions come from printing/print_iprint.c  */
 
diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c
index b7198d3..23d9a86 100644
--- a/source3/printing/print_aix.c
+++ b/source3/printing/print_aix.c
@@ -86,7 +86,7 @@ bool aix_cache_reload(void)
 				/* 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);
@@ -101,7 +101,7 @@ bool aix_cache_reload(void)
 			} 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 --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 077d82b..ff19de2 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -163,6 +163,7 @@ static bool process_cups_printers_response(TALLOC_CTX *mem_ctx,
 	ipp_attribute_t	*attr;
 	char *name;
 	char *info;
+	char *location = NULL;
 	struct pcap_printer *printer;
 	bool ret_ok = false;
 
@@ -206,6 +207,16 @@ static bool process_cups_printers_response(TALLOC_CTX *mem_ctx,
 				}
 			}
 
+			if (strcmp(attr->name, "printer-location") == 0 &&
+			    attr->value_tag == IPP_TAG_TEXT) {
+				if (!pull_utf8_talloc(mem_ctx,
+						&location,
+						attr->values[0].string.text,
+						&size)) {
+					goto err_out;
+				}
+			}
+
 			attr = attr->next;
 		}
 
@@ -229,6 +240,7 @@ static bool process_cups_printers_response(TALLOC_CTX *mem_ctx,
 		pcap_data->printers = printer;
 		pcap_data->printers[pcap_data->count].name = name;
 		pcap_data->printers[pcap_data->count].info = info;
+		pcap_data->printers[pcap_data->count].location = location;
 		pcap_data->count++;
 	}
 
@@ -252,7 +264,8 @@ static bool cups_cache_reload_async(int fd)
 	static const char *requested[] =/* Requested attributes */
 			{
 			  "printer-name",
-			  "printer-info"
+			  "printer-info",
+			  "printer-location"
 			};
 	bool ret = False;
 	enum ndr_err_code ndr_ret;
@@ -478,7 +491,8 @@ static void cups_async_callback(struct event_context *event_ctx,
 	for (i = 0; i < pcap_data.count; i++) {
 		ret_ok = pcap_cache_add_specific(&tmp_pcap_cache,
 						 pcap_data.printers[i].name,
-						 pcap_data.printers[i].info);
+						 pcap_data.printers[i].info,
+						 pcap_data.printers[i].location);
 		if (!ret_ok) {
 			DEBUG(0, ("failed to add to tmp pcap cache\n"));
 			goto err_out;
@@ -1573,163 +1587,6 @@ struct printif	cups_printif =
 	cups_job_submit,
 };
 
-bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
-				const char *printername,
-				char **comment,
-				char **location)
-{
-	TALLOC_CTX *frame = talloc_stackframe();
-	http_t		*http = NULL;		/* HTTP connection to server */
-	ipp_t		*request = NULL,	/* IPP Request */
-			*response = NULL;	/* IPP Response */
-	ipp_attribute_t	*attr;		/* Current attribute */
-	cups_lang_t	*language = NULL;	/* Default language */
-	char		uri[HTTP_MAX_URI];
-	char *sharename = NULL;
-	char *name = NULL;
-	static const char *requested[] =/* Requested attributes */
-			{
-			  "printer-name",
-			  "printer-info",
-			  "printer-location"
-			};
-	bool ret = False;
-	size_t size;
-
-	DEBUG(5, ("pulling %s location\n", printername));
-
-	/*
-	 * Make sure we don't ask for passwords...
-	 */
-
-        cupsSetPasswordCB(cups_passwd_cb);
-
-	/*
-	 * Try to connect to the server...
-	 */
-
-	if ((http = cups_connect(frame)) == NULL) {
-		goto out;
-	}
-
-	request = ippNew();
-
-	request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
-	request->request.op.request_id   = 1;
-
-	language = cupsLangDefault();
-
-	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
-                     "attributes-charset", NULL, "utf-8");
-
-	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
-                     "attributes-natural-language", NULL, language->language);
-
-	if (!push_utf8_talloc(frame, &sharename, printername, &size)) {
-		goto out;
-	}
-	slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s",
-		 sharename);
-
-	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
-                     "printer-uri", NULL, uri);
-
-        ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
-	              "requested-attributes",
-		      (sizeof(requested) / sizeof(requested[0])),
-		      NULL, requested);
-
-	/*
-	 * Do the request and get back a response...
-	 */
-
-	if ((response = cupsDoRequest(http, request, "/")) == NULL) {
-		DEBUG(0,("Unable to get printer attributes - %s\n",
-			 ippErrorString(cupsLastError())));
-		goto out;
-	}
-
-	for (attr = response->attrs; attr != NULL;) {
-		/*
-		 * Skip leading attributes until we hit a printer...
-		 */
-
-		while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
-			attr = attr->next;
-
-		if (attr == NULL)
-        		break;
-
-		/*
-		 * Pull the needed attributes from this printer...
-		 */
-
-		while ( attr && (attr->group_tag == IPP_TAG_PRINTER) ) {
-        		if (strcmp(attr->name, "printer-name") == 0 &&
-			    attr->value_tag == IPP_TAG_NAME) {
-				if (!pull_utf8_talloc(frame,
-						&name,
-						attr->values[0].string.text,
-						&size)) {
-					goto out;
-				}
-			}
-
-			/* Grab the comment if we don't have one */
-        		if ( (strcmp(attr->name, "printer-info") == 0)
-			     && (attr->value_tag == IPP_TAG_TEXT))
-			{
-				if (!pull_utf8_talloc(mem_ctx,
-						comment,
-						attr->values[0].string.text,
-						&size)) {
-					goto out;
-				}
-				DEBUG(5,("cups_pull_comment_location: Using cups comment: %s\n",
-					 *comment));
-			}
-
-			/* Grab the location if we don't have one */
-			if ( (strcmp(attr->name, "printer-location") == 0)
-			     && (attr->value_tag == IPP_TAG_TEXT))
-			{
-				if (!pull_utf8_talloc(mem_ctx,
-						location,
-						attr->values[0].string.text,
-						&size)) {
-					goto out;
-				}
-				DEBUG(5,("cups_pull_comment_location: Using cups location: %s\n",
-					 *location));
-			}
-
-        		attr = attr->next;
-		}
-
-		/*
-		 * We have everything needed...
-		 */
-
-		if (name != NULL)
-			break;
-	}
-
-	ret = True;
-
- out:
-	if (response)
-		ippDelete(response);
-
-	if (language)
-		cupsLangFree(language);
-
-	if (http)
-		httpClose(http);
-
-	TALLOC_FREE(frame);
-	return ret;
-}
-
 #else
  /* this keeps fussy compilers happy */
  void print_cups_dummy(void);
diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c
index ea375da..1392cba 100644
--- a/source3/printing/print_iprint.c
+++ b/source3/printing/print_iprint.c
@@ -297,7 +297,7 @@ static int iprint_cache_add_printer(http_t *http,
 		*/
 
 		if (name != NULL && !secure && smb_enabled) 
-			pcap_cache_add(name, info);
+			pcap_cache_add(name, info, NULL);
 	}
 
  out:
diff --git a/source3/printing/print_standard.c b/source3/printing/print_standard.c
index a846093..6a86d84 100644
--- a/source3/printing/print_standard.c
+++ b/source3/printing/print_standard.c
@@ -120,7 +120,7 @@ bool std_pcap_cache_reload(const char *pcap_name)
 		comment[60] = 0;
 		name[MAXPRINTERLEN] = 0;
 
-		if (*name && !pcap_cache_add(name, comment)) {
+		if (*name && !pcap_cache_add(name, comment, NULL)) {
 			x_fclose(pcap_file);
 			return false;
 		}
diff --git a/source3/printing/print_svid.c b/source3/printing/print_svid.c
index 4929be1..2226493 100644
--- a/source3/printing/print_svid.c
+++ b/source3/printing/print_svid.c
@@ -111,7 +111,7 @@ bool sysv_cache_reload(void)
 			*tmp = '\0';
 		
 		/* add it to the cache */
-		if (!pcap_cache_add(name, NULL)) {
+		if (!pcap_cache_add(name, NULL, NULL)) {
 			TALLOC_FREE(lines);
 			return False;
 		}
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c
index d8be893..d28278d 100644
--- a/source3/printing/printer_list.c
+++ b/source3/printing/printer_list.c
@@ -27,7 +27,7 @@
 #define PL_KEY_PREFIX "PRINTERLIST/PRN/"
 #define PL_KEY_FORMAT PL_KEY_PREFIX"%s"
 #define PL_TIMESTAMP_KEY "PRINTERLIST/GLOBAL/LAST_REFRESH"
-#define PL_DATA_FORMAT "ddPP"
+#define PL_DATA_FORMAT "ddPPP"
 #define PL_TSTAMP_FORMAT "dd"
 
 static struct db_context *get_printer_list_db(void)
@@ -65,6 +65,7 @@ bool printer_list_parent_init(void)
 NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
 				  const char *name,
 				  const char **comment,
+				  const char **location,
 				  time_t *last_refresh)
 {
 	struct db_context *db;
@@ -73,6 +74,7 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
 	uint32_t time_h, time_l;
 	char *nstr = NULL;
 	char *cstr = NULL;
+	char *lstr = NULL;
 	NTSTATUS status;
 	int ret;
 
@@ -96,7 +98,7 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
 
 	ret = tdb_unpack(data.dptr, data.dsize,
 			 PL_DATA_FORMAT,
-			 &time_h, &time_l, &nstr, &cstr);
+			 &time_h, &time_l, &nstr, &cstr, &lstr);
 	if (ret == -1) {
 		DEBUG(1, ("Failed to un pack printer data"));
 		status = NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -116,6 +118,15 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
 		}
 	}
 
+	if (location) {
+		*location = talloc_strdup(mem_ctx, lstr);
+		if (*location == NULL) {
+			DEBUG(1, ("Failed to strdup location!\n"));
+			status = NT_STATUS_NO_MEMORY;
+			goto done;
+		}
+	}
+
 	status = NT_STATUS_OK;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list