Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge pull request #1267 from rbgarga/user_agent
Baptiste Daroussin committed 10 years ago
commit b9ff37db09d28ce6176f81c70c846d10693a2180
parent f16daa9
3 files changed +15 -2
modified docs/pkg.conf.5
@@ -136,6 +136,9 @@ services during package installation and deinstallation.
Services are only started on installation if they are enabled in
.Pa /etc/rc.conf .
Default: NO.
+
.It Cm HTTP_USER_AGENT: string
+
Define User-agent to be sent to HTTP server when getting reposity
+
data
.It Cm INDEXDIR: string
If set, the directory to search for
.Cm INDEXFILE
modified libpkg/pkg_config.c
@@ -225,6 +225,12 @@ static struct config_entry c[] = {
	},
	{
		PKG_STRING,
+
		"HTTP_USER_AGENT",
+
		"pkg/"PKGVERSION,
+
		"HTTP User-Agent",
+
	},
+
	{
+
		PKG_STRING,
		"EVENT_PIPE",
		NULL,
		"Send all events to the specified fifo or Unix socket",
@@ -761,6 +767,7 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)
	const char *buf, *walk, *value, *key, *k;
	const char *evkey = NULL;
	const char *nsname = NULL;
+
	const char *useragent = NULL;
	const char *evpipe = NULL;
	const ucl_object_t *cur, *object;
	ucl_object_t *obj = NULL, *o, *ncfg;
@@ -1056,11 +1063,13 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)
			setenv(evkey, ucl_object_tostring_forced(cur), 1);
	}

+
	/* Set user-agent */
+
	useragent = pkg_object_string(pkg_config_get("HTTP_USER_AGENT"));
+
	setenv("HTTP_USER_AGENT", useragent, 1);
+

	/* load the repositories */
	load_repositories(reposdir, flags);

-
	setenv("HTTP_USER_AGENT", "pkg/"PKGVERSION, 1);
-

	/* bypass resolv.conf with specified NAMESERVER if any */
	nsname = pkg_object_string(pkg_config_get("NAMESERVER"));
	if (nsname != NULL)
modified src/pkg.conf.sample
@@ -36,6 +36,7 @@
#PERMISSIVE = false;
#REPO_AUTOUPDATE = true;
#NAMESERVER = "";
+
#HTTP_USER_AGENT = "Custom_User_Manager";
#EVENT_PIPE = "";
#FETCH_TIMEOUT = 30;
#UNSET_TIMESTAMP = false;