diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml
index d40384e13..dae0044ca 100644
--- a/.github/workflows/test-agent.yml
+++ b/.github/workflows/test-agent.yml
@@ -158,6 +158,12 @@ jobs:
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
-e ENABLE_COVERAGE=${{matrix.codecov}}
$IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-${{ steps.get-check-variant.outputs.AGENT_CHECK_VARIANT }}
+ - name: Run newrelic-install tests
+ run: >
+ docker run --rm --platform linux/${{matrix.arch}}
+ -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
+ -e ENABLE_COVERAGE=${{matrix.codecov}}
+ $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make verify-inject-script
- name: Save newrelic.so for integration tests
uses: actions/upload-artifact@v4
with:
diff --git a/Makefile b/Makefile
index 0e95237d5..b68b8c871 100644
--- a/Makefile
+++ b/Makefile
@@ -205,12 +205,20 @@ daemon-clean:
# missing from the $PATH.
#
-installer: bin/newrelic-install bin/newrelic-iutil | bin/
+installer: bin/newrelic-install bin/newrelic-install-inject-envvars.php bin/newrelic-install-php-cfg-mappings.php bin/newrelic-iutil | bin/
bin/newrelic-install: agent/newrelic-install.sh Makefile VERSION | bin/
sed -e "/nrversion:=/s,UNSET,$(AGENT_VERSION)," $< > $@
chmod 755 $@
+bin/newrelic-install-inject-envvars.php: agent/newrelic-install-inject-envvars.php Makefile | bin/
+ cp $< $@
+ chmod 755 $@
+
+bin/newrelic-install-php-cfg-mappings.php: agent/newrelic-install-php-cfg-mappings.php Makefile | bin/
+ cp $< $@
+ chmod 755 $@
+
bin/newrelic-iutil: agent/install-util.c Makefile VERSION | bin/
$(CC) -DNR_VERSION="\"$(AGENT_VERSION)\"" $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)
@@ -362,6 +370,19 @@ integration-events-limits: bin/integration_runner
echo "# PHP=$${PHP}"; \
done;
+#
+# Verify env var injection script mapping has all INI values
+# Requires test APIs to be enabled in agent
+#
+.PHONY: verify-inject-script
+verify-inject-script: agent
+ (cd tests/newrelic-installer; \
+ php -d extension=../../agent/.libs/newrelic.so \
+ verify_inject_envvars_script_mapping.php)
+ (cd tests/newrelic-installer; \
+ php -d extension=../../agent/.libs/newrelic.so \
+ verify_inject_envvars_script_injection.php)
+
#
# Code profiling
#
diff --git a/agent/newrelic-install-inject-envvars.php b/agent/newrelic-install-inject-envvars.php
new file mode 100644
index 000000000..3c5efa756
--- /dev/null
+++ b/agent/newrelic-install-inject-envvars.php
@@ -0,0 +1,118 @@
+= 7.0\n");
+ exit(1);
+}
+
+/* Mapping from INI name to environment variable name
+ * Expected form:
+ * define('INI_ENVVAR_MAP', array(....));
+ */
+require "newrelic-install-php-cfg-mappings.php";
+
+/* Verify that ini/envvar mapping was injected and is defined */
+if (!defined('INI_ENVVAR_MAP')) {
+ failure("INI/ENVVAR mapping was not detected - cannot proceed!");
+ exit(1);
+}
+
+/* Verify input INI file exists */
+if (3 != $argc) {
+ failure(" missing required arguments\n" .
+ "Usage: newrelic-install-inject-envvars.php