Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable capabilities in deb/rpm postinstall #396

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/buildscripts/packaging/fpm/deb/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ sudo fpm -s dir -t deb -n "$PKG_NAME" -v "$VERSION" -f -p "$OUTPUT_DIR" \
--architecture "$ARCH" \
--deb-dist "stable" \
--deb-use-file-permissions \
--depends libcap2-bin \
--before-install "$PREINSTALL_PATH" \
--after-install "$POSTINSTALL_PATH" \
--before-remove "$PREUNINSTALL_PATH" \
Expand Down
2 changes: 2 additions & 0 deletions internal/buildscripts/packaging/fpm/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

setcap CAP_SYS_PTRACE,CAP_DAC_READ_SEARCH=+eip /usr/bin/otelcol

if [ -f /usr/lib/splunk-otel-collector/agent-bundle/bin/patch-interpreter ]; then
/usr/lib/splunk-otel-collector/agent-bundle/bin/patch-interpreter /usr/lib/splunk-otel-collector/agent-bundle
fi
Expand Down
1 change: 1 addition & 0 deletions internal/buildscripts/packaging/fpm/rpm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ sudo fpm -s dir -t rpm -n "$PKG_NAME" -v "$VERSION" -f -p "$OUTPUT_DIR" \
--architecture "$ARCH" \
--rpm-summary "$PKG_DESCRIPTION" \
--rpm-use-file-permissions \
--depends libcap \
--before-install "$PREINSTALL_PATH" \
--after-install "$POSTINSTALL_PATH" \
--before-remove "$PREUNINSTALL_PATH" \
Expand Down
10 changes: 10 additions & 0 deletions internal/buildscripts/packaging/tests/package_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def test_collector_package_install(distro):
pkg_base = os.path.basename(pkg_path)

with run_distro_container(distro) as container:
# install setcap dependency
if distro in RPM_DISTROS:
if container.exec_run("command -v yum").exit_code == 0:
run_container_cmd(container, "yum install -y libcap")
else:
run_container_cmd(container, "dnf install -y libcap")
else:
run_container_cmd(container, "apt-get update")
run_container_cmd(container, "apt-get install -y libcap2-bin")

copy_file_into_container(container, pkg_path, f"/test/{pkg_base}")

try:
Expand Down