rpms/PackageKit/F-11 PackageKit-0.4.6-fix-http_proxy-uris.patch, NONE, 1.1 PackageKit.spec, 1.106, 1.107

Richard Hughes rhughes at fedoraproject.org
Fri Apr 24 14:50:30 UTC 2009


Author: rhughes

Update of /cvs/pkgs/rpms/PackageKit/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv27194

Modified Files:
	PackageKit.spec 
Added Files:
	PackageKit-0.4.6-fix-http_proxy-uris.patch 
Log Message:
* Fri Apr 24 2009 Richard Hughes  <rhughes at redhat.com> - 0.4.6-9
- Backport a patch from upstream to fix URI escaping of http_proxy when
  using a proxy set in gnome-network-properties.
- Fixes #491859


PackageKit-0.4.6-fix-http_proxy-uris.patch:

--- NEW FILE PackageKit-0.4.6-fix-http_proxy-uris.patch ---
commit 7af1423a989cac5af9cada6fbc5972f2b769c56b
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Apr 24 15:42:55 2009 +0100

    bugfix: To fix spawned backends, http_proxy has to be a URI not a bare proxy. Fixes RH#491859

diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
index 2942584..a283e97 100644
--- a/src/pk-backend-spawn.c
+++ b/src/pk-backend-spawn.c
@@ -538,6 +538,33 @@ pk_backend_spawn_stderr_cb (PkBackendSpawn *spawn, const gchar *line, PkBackendS
 }
 
 /**
+ * pk_backend_spawn_convert_uri:
+ *
+ * Our proxy variable is typically 'username:password at server:port'
+ * but http_proxy expects 'http://username:password@server:port/'
+ **/
+static gchar *
+pk_backend_spawn_convert_uri (const gchar *proxy)
+{
+	GString *string;
+	string = g_string_new (proxy);
+
+	/* if we didn't specify a prefix, add a default one */
+	if (!g_str_has_prefix (proxy, "http://") &&
+	    !g_str_has_prefix (proxy, "https://") &&
+	    !g_str_has_prefix (proxy, "ftp://")) {
+		g_string_prepend (string, "http://");
+	}
+
+	/* if we didn't specify a trailing slash, add one */
+	if (!g_str_has_suffix (proxy, "/")) {
+		g_string_append_c (string, '/');
+	}
+
+	return g_string_free (string, FALSE);
+}
+
+/**
  * pk_backend_spawn_get_envp:
  *
  * Return all the environment variables the script will need
@@ -548,6 +575,7 @@ pk_backend_spawn_get_envp (PkBackendSpawn *backend_spawn)
 	gchar **envp;
 	gchar *value;
 	gchar *line;
+	gchar *uri;
 	GPtrArray *array;
 	gboolean ret;
 
@@ -556,18 +584,22 @@ pk_backend_spawn_get_envp (PkBackendSpawn *backend_spawn)
 	/* http_proxy */
 	value = pk_backend_get_proxy_http (backend_spawn->priv->backend);
 	if (!egg_strzero (value)) {
-		line = g_strdup_printf ("%s=%s", "http_proxy", value);
+		uri = pk_backend_spawn_convert_uri (value);
+		line = g_strdup_printf ("%s=%s", "http_proxy", uri);
 		egg_debug ("setting evp '%s'", line);
 		g_ptr_array_add (array, line);
+		g_free (uri);
 	}
 	g_free (value);
 
 	/* ftp_proxy */
 	value = pk_backend_get_proxy_ftp (backend_spawn->priv->backend);
 	if (!egg_strzero (value)) {
-		line = g_strdup_printf ("%s=%s", "ftp_proxy", value);
+		uri = pk_backend_spawn_convert_uri (value);
+		line = g_strdup_printf ("%s=%s", "ftp_proxy", uri);
 		egg_debug ("setting evp '%s'", line);
 		g_ptr_array_add (array, line);
+		g_free (uri);
 	}
 	g_free (value);
 
@@ -897,6 +929,7 @@ pk_backend_test_spawn (EggTest *test)
 	const gchar *text;
 	guint refcount;
 	gboolean ret;
+	gchar *uri;
 
 	loop = g_main_loop_new (NULL, FALSE);
 
@@ -1029,6 +1062,26 @@ pk_backend_test_spawn (EggTest *test)
 	egg_test_assert (test, !ret);
 
 	/************************************************************
+	 **********         Check uri conversion          ***********
+	 ************************************************************/
+	egg_test_title (test, "convert proxy uri (bare)");
+	uri = pk_backend_spawn_convert_uri ("username:password at server:port");
+	egg_test_assert (test, (g_strcmp0 (uri, "http://username:password@server:port/") == 0));
+	g_free (uri);
+
+	/************************************************************/
+	egg_test_title (test, "convert proxy uri (full)");
+	uri = pk_backend_spawn_convert_uri ("http://username:password@server:port/");
+	egg_test_assert (test, (g_strcmp0 (uri, "http://username:password@server:port/") == 0));
+	g_free (uri);
+
+	/************************************************************/
+	egg_test_title (test, "convert proxy uri (partial)");
+	uri = pk_backend_spawn_convert_uri ("ftp://username:password@server:port");
+	egg_test_assert (test, (g_strcmp0 (uri, "ftp://username:password@server:port/") == 0));
+	g_free (uri);
+
+	/************************************************************
 	 **********        Check parsing common out       ***********
 	 ************************************************************/
 	egg_test_title (test, "test pk_backend_spawn_parse_common_out Package");


Index: PackageKit.spec
===================================================================
RCS file: /cvs/pkgs/rpms/PackageKit/F-11/PackageKit.spec,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- PackageKit.spec	24 Apr 2009 09:18:00 -0000	1.106
+++ PackageKit.spec	24 Apr 2009 14:49:59 -0000	1.107
@@ -10,7 +10,7 @@
 Name:      PackageKit
 Version:   0.4.6
 #Release:   0.3.%{?alphatag}git%{?dist}
-Release:   8%{?dist}
+Release:   9%{?dist}
 License:   GPLv2+
 Group:     System Environment/Libraries
 URL:       http://www.packagekit.org
@@ -57,6 +57,9 @@
 # Already upstream: 5c3396990ea6e973b239a168828c4ad64c58e91b
 Patch12:   PackageKit-0.4.6-dont-run-pkplugin-under-pk.patch
 
+# Already upstream: 7af1423a989cac5af9cada6fbc5972f2b769c56b
+Patch13:   PackageKit-0.4.6-fix-http_proxy-uris.patch
+
 Requires: dbus >= %{dbus_version}
 Requires: dbus-glib >= %{dbus_glib_version}
 Requires: PackageKit-glib = %{version}-%{release}
@@ -268,6 +271,7 @@
 %patch10 -p1 -b .send-package-finished
 %patch11 -p1 -b .disallow-sigkill
 %patch12 -p1 -b .no-plugin-under-pk
+%patch13 -p1 -b .http_proxy
 
 %build
 %configure --enable-yum --enable-smart --with-default-backend=yum --disable-local --disable-ruck
@@ -462,6 +466,11 @@
 %{_includedir}/PackageKit/backend/*.h
 
 %changelog
+* Fri Apr 24 2009 Richard Hughes  <rhughes at redhat.com> - 0.4.6-9
+- Backport a patch from upstream to fix URI escaping of http_proxy when
+  using a proxy set in gnome-network-properties.
+- Fixes #491859
+
 * Fri Apr 24 2009 Richard Hughes  <rhughes at redhat.com> - 0.4.6-8
 - Backport a patch from upstream to stop refresh-packagekit from running
   when the script is running under PackageKit. This fixes the bug where




More information about the fedora-extras-commits mailing list