[pacman-dev] [PATCH 2/4] pacman: use alpm method to set useragent

Dave Reisner d at falconindy.com
Mon Mar 28 15:15:41 EDT 2011


The call for this needs to be done a little later now since it requires
that the handle be initialized.

Signed-off-by: Dave Reisner <d at falconindy.com>
---
 src/pacman/pacman.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index eac9c9c..381d2bc 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -253,13 +253,13 @@ static void localize(void)
  */
 static void setuseragent(void)
 {
-	char agent[101];
+	char *agent;
 	struct utsname un;
 
 	uname(&un);
-	snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s",
+	pm_asprintf(&agent, "pacman/%s (%s %s) libalpm/%s",
 			PACKAGE_VERSION, un.sysname, un.machine, alpm_version());
-	setenv("HTTP_USER_AGENT", agent, 0);
+	alpm_option_set_useragent(agent);
 }
 
 static void setarch(const char *arch)
@@ -1360,9 +1360,6 @@ int main(int argc, char *argv[])
 	localize();
 #endif
 
-	/* set user agent for downloading */
-	setuseragent();
-
 	/* init config data */
 	config = config_new();
 
@@ -1387,6 +1384,9 @@ int main(int argc, char *argv[])
 	alpm_option_set_signaturedir(GPGDIR);
 	alpm_option_set_logfile(LOGFILE);
 
+	/* set user agent for downloading */
+	setuseragent();
+
 	/* Priority of options:
 	 * 1. command line
 	 * 2. config file
-- 
1.7.4.2



More information about the pacman-dev mailing list