Skip to content

selinux: add pcp-import policy module for local context recording tools#2657

Merged
natoscott merged 1 commit into
performancecopilot:mainfrom
natoscott:pcp-selinux-import
Jul 20, 2026
Merged

selinux: add pcp-import policy module for local context recording tools#2657
natoscott merged 1 commit into
performancecopilot:mainfrom
natoscott:pcp-selinux-import

Conversation

@natoscott

@natoscott natoscott commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • New SELinux policy module pcp-import for PCP tools operating in PM_CONTEXT_LOCAL mode without pmcd (pcp-atop, sysstat sadc with -O pcp)
  • Single reusable pcp_import_t domain — future import tools just add their binary path to the .fc file
  • Augments existing sysstat_t domain via optional_policy when sysstat is installed (no sysstat packaging changes needed)
  • Works independently of pcp-selinux (which covers pmcd/pmlogger/pmproxy/pmie)
  • New pcp-selinux-import RPM subpackage, weak-required by pcp-libs when SELinux is active
  • Rename PCP_IMPORT_DIRPCP_IMPORTRUN_DIR (runtime status, /run/pmimport)
  • New PCP_IMPORTLOG_DIR (/var/log, base directory for import tool archives)
  • pcp-atop uses $PCP_IMPORTLOG_DIR/atop for daily archives

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@natoscott, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 99a85216-67b5-4ebc-b195-6c57e42b19ac

📥 Commits

Reviewing files that changed from the base of the PR and between a6400b7 and 327acb7.

📒 Files selected for processing (26)
  • build/rpm/pcp.spec.in
  • build/rpm/redhat.spec
  • configure
  • configure.ac
  • man/man3/pmisetimportprogram.3
  • qa/2005
  • qa/2007
  • qa/518
  • src/include/builddefs.in
  • src/include/pcp.conf.in
  • src/libpcp_import/src/GNUmakefile
  • src/libpcp_import/src/archive.c
  • src/libpcp_import/src/import.c
  • src/libpcp_import/src/libpcp_import.conf.in
  • src/libpcp_import/src/private.h
  • src/pcp/atop/GNUmakefile
  • src/pcp/atop/atop-daily.sh
  • src/pcp/atop/atop.conf
  • src/pcp/atop/atop.service.in
  • src/pmdas/pmimport/help
  • src/pmdas/pmimport/pmda_pmimport.c
  • src/selinux/GNUmakefile
  • src/selinux/import/GNUmakefile
  • src/selinux/import/pcp-import.fc
  • src/selinux/import/pcp-import.if
  • src/selinux/import/pcp-import.te
📝 Walkthrough

Walkthrough

The change separates PCP import runtime and log directories, updates import and atop consumers, adds a dedicated SELinux import policy, and packages that policy in a new RPM subpackage.

Changes

Import runtime and SELinux integration

Layer / File(s) Summary
Import directory contract and consumers
configure, configure.ac, src/include/*, src/libpcp_import/src/*, src/pmdas/pmimport/*, qa/*, man/man3/pmisetimportprogram.3
Adds separate runtime and log directory settings, and redirects import sidecar creation, cleanup, discovery, documentation, and QA checks to PCP_IMPORTRUN_DIR.
Atop log directory integration
src/pcp/atop/*
Atop installation, service configuration, daily processing, and archive defaults use PCP_IMPORTLOG_DIR/atop.
SELinux import policy build
src/selinux/GNUmakefile, src/selinux/import/*
Adds the pcp-import policy module, file contexts, interfaces, compilation/compression rules, and SELinux-enabled build/install wiring.
SELinux import RPM packaging
build/rpm/pcp.spec.in, build/rpm/redhat.spec
Adds pcp-selinux-import, conditional dependencies, split manifests, policy scriptlets, and %files entries.

Sequence Diagram(s)

sequenceDiagram
  participant configure
  participant libpcp_import
  participant pmda_pmimport
  configure->>libpcp_import: Provide PCP_IMPORTRUN_DIR
  libpcp_import->>libpcp_import: Create and remove status sidecars
  pmda_pmimport->>libpcp_import: Scan PCP_IMPORTRUN_DIR
Loading

Possibly related PRs

Suggested reviewers: kmcdonell

Poem

Runtime burrows in /run,
Logs rest where archives are spun.
SELinux hops into place,
RPMs label every space.
Sidecars find their proper home.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a pcp-import SELinux policy module for local context recording tools.
Description check ✅ Passed The description matches the changeset and covers the new SELinux module, packaging, and directory renames.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pcp/atop/atop-daily.sh`:
- Line 66: Update the default LOGPATH assignment to quote the parameter
expansion, preventing word splitting and pathname expansion when LOGPATH or
PCP_IMPORTLOG_DIR contains whitespace or glob characters.

In `@src/selinux/import/pcp-import.if`:
- Around line 59-60: Add the pmimport PID-file transition alongside the existing
manage_files_pattern and manage_dirs_pattern declarations in
src/selinux/import/pcp-import.if lines 59-60, and add the corresponding
files_pid_filetrans declaration in src/selinux/import/pcp-import.te lines
143-144, covering both dir and file types.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 5531a53a-7317-46e1-81d7-9df92c340621

📥 Commits

Reviewing files that changed from the base of the PR and between 4529a26 and 576a3d7.

📒 Files selected for processing (26)
  • build/rpm/pcp.spec.in
  • build/rpm/redhat.spec
  • configure
  • configure.ac
  • man/man3/pmisetimportprogram.3
  • qa/2005
  • qa/2007
  • qa/518
  • src/include/builddefs.in
  • src/include/pcp.conf.in
  • src/libpcp_import/src/GNUmakefile
  • src/libpcp_import/src/archive.c
  • src/libpcp_import/src/import.c
  • src/libpcp_import/src/libpcp_import.conf.in
  • src/libpcp_import/src/private.h
  • src/pcp/atop/GNUmakefile
  • src/pcp/atop/atop-daily.sh
  • src/pcp/atop/atop.conf
  • src/pcp/atop/atop.service.in
  • src/pmdas/pmimport/help
  • src/pmdas/pmimport/pmda_pmimport.c
  • src/selinux/GNUmakefile
  • src/selinux/import/GNUmakefile
  • src/selinux/import/pcp-import.fc
  • src/selinux/import/pcp-import.if
  • src/selinux/import/pcp-import.te

Comment thread src/pcp/atop/atop-daily.sh Outdated
Comment thread src/selinux/import/pcp-import.if
@natoscott
natoscott force-pushed the pcp-selinux-import branch from 576a3d7 to fe643f2 Compare July 17, 2026 06:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
build/rpm/redhat.spec (1)

2289-2304: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the unnecessary pcp-libs dependency to avoid a circular dependency.

The pcp-selinux-import package provides SELinux policy files and does not link against the C libraries. Requiring pcp-libs creates a cyclic dependency because pcp-libs itself conditionally requires pcp-selinux-import.

Removing it aligns with pcp.spec.in and the existing pcp-selinux subpackage, which also omit this dependency.

♻️ Proposed refactor
 %package selinux-import
 License: GPL-2.0-or-later AND CC-BY-3.0
 Summary: SELinux policy for PCP local context recording tools
 URL: https://pcp.io
-Requires: pcp-libs = %{version}-%{release}
 Requires: policycoreutils selinux-policy-targeted
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/rpm/redhat.spec` around lines 2289 - 2304, Remove the “Requires:
pcp-libs = %{version}-%{release}” entry from the selinux-import package
definition, while preserving its policycoreutils and selinux-policy-targeted
dependencies and the surrounding package metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build/rpm/pcp.spec.in`:
- Around line 285-287: Guard the pcp-selinux-import boolean dependency in
build/rpm/pcp.spec.in lines 285-287 with the established 0%{?fedora} >= 36 ||
0%{?rhel} >= 9 check, retaining an unconditional Requires fallback for older
systems. Apply the corresponding 0%{?fedora} >= 35 || 0%{?rhel} >= 8 guard to
the same dependency in build/rpm/redhat.spec lines 467-469.

---

Nitpick comments:
In `@build/rpm/redhat.spec`:
- Around line 2289-2304: Remove the “Requires: pcp-libs = %{version}-%{release}”
entry from the selinux-import package definition, while preserving its
policycoreutils and selinux-policy-targeted dependencies and the surrounding
package metadata.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 68d3d528-25b0-4114-9343-d883fb2e9271

📥 Commits

Reviewing files that changed from the base of the PR and between 576a3d7 and fe643f2.

📒 Files selected for processing (26)
  • build/rpm/pcp.spec.in
  • build/rpm/redhat.spec
  • configure
  • configure.ac
  • man/man3/pmisetimportprogram.3
  • qa/2005
  • qa/2007
  • qa/518
  • src/include/builddefs.in
  • src/include/pcp.conf.in
  • src/libpcp_import/src/GNUmakefile
  • src/libpcp_import/src/archive.c
  • src/libpcp_import/src/import.c
  • src/libpcp_import/src/libpcp_import.conf.in
  • src/libpcp_import/src/private.h
  • src/pcp/atop/GNUmakefile
  • src/pcp/atop/atop-daily.sh
  • src/pcp/atop/atop.conf
  • src/pcp/atop/atop.service.in
  • src/pmdas/pmimport/help
  • src/pmdas/pmimport/pmda_pmimport.c
  • src/selinux/GNUmakefile
  • src/selinux/import/GNUmakefile
  • src/selinux/import/pcp-import.fc
  • src/selinux/import/pcp-import.if
  • src/selinux/import/pcp-import.te
🚧 Files skipped from review as they are similar to previous changes (20)
  • src/selinux/import/pcp-import.fc
  • src/include/pcp.conf.in
  • src/libpcp_import/src/private.h
  • src/pmdas/pmimport/help
  • man/man3/pmisetimportprogram.3
  • src/pcp/atop/atop.conf
  • src/pmdas/pmimport/pmda_pmimport.c
  • src/pcp/atop/atop-daily.sh
  • src/include/builddefs.in
  • src/selinux/import/pcp-import.if
  • src/selinux/import/GNUmakefile
  • qa/2005
  • src/pcp/atop/GNUmakefile
  • src/libpcp_import/src/archive.c
  • qa/2007
  • src/libpcp_import/src/import.c
  • configure.ac
  • src/selinux/import/pcp-import.te
  • src/selinux/GNUmakefile
  • configure

Comment thread build/rpm/pcp.spec.in
@natoscott
natoscott force-pushed the pcp-selinux-import branch 2 times, most recently from 7f40b9b to a6400b7 Compare July 17, 2026 06:41
Add a new SELinux policy module (pcp-import) for PCP tools that operate
in PM_CONTEXT_LOCAL mode without pmcd — loading DSO PMDAs directly and
writing PCP archives via libpcp_import.  This covers pcp-atop and
sysstat's sadc (with -O pcp), and provides a reusable pcp_import_t
domain for future import tools.

The pcp-import module is independent of the existing pcp-selinux
package (which covers pmcd/pmlogger/pmproxy/pmie) and works when only
pcp-libs is installed.  The sysstat_t domain from the base targeted
policy is augmented via optional_policy when sysstat is installed.

Rename PCP_IMPORT_DIR to PCP_IMPORTRUN_DIR for clarity (/run/pmimport
status files) and add PCP_IMPORTLOG_DIR (/var/log, base directory for
import tool archives).  pcp-atop uses PCP_IMPORTLOG_DIR/atop for its
daily archives.

New pcp-selinux-import RPM subpackage, weak-required by pcp-libs when
selinux-policy-targeted is installed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@natoscott
natoscott force-pushed the pcp-selinux-import branch from a6400b7 to 327acb7 Compare July 17, 2026 06:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
build/rpm/redhat.spec (1)

2498-2498: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use %{_localstatedir}/run/pmimport for compatibility.

The %{_rundir} macro may not be defined on older distributions (such as RHEL 6) that this spec file still supports, which will cause the build to fail. Furthermore, it is inconsistent with the %{_localstatedir}/run/... pattern used for existing runtime directories in this file (e.g., %{_localstatedir}/run/pcp).

🛠 Proposed fix
-echo %{_rundir}/pmimport >>pcp-libs-files
+echo %{_localstatedir}/run/pmimport >>pcp-libs-files
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/rpm/redhat.spec` at line 2498, Update the pcp-libs-files entry to use
the %{_localstatedir}/run/pmimport path instead of %{_rundir}/pmimport, matching
the existing runtime-directory pattern and preserving compatibility with older
distributions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@build/rpm/redhat.spec`:
- Line 2498: Update the pcp-libs-files entry to use the
%{_localstatedir}/run/pmimport path instead of %{_rundir}/pmimport, matching the
existing runtime-directory pattern and preserving compatibility with older
distributions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: bfb3dd4e-2b40-4a98-b493-75f4d8dfb4b3

📥 Commits

Reviewing files that changed from the base of the PR and between 7f40b9b and a6400b7.

📒 Files selected for processing (26)
  • build/rpm/pcp.spec.in
  • build/rpm/redhat.spec
  • configure
  • configure.ac
  • man/man3/pmisetimportprogram.3
  • qa/2005
  • qa/2007
  • qa/518
  • src/include/builddefs.in
  • src/include/pcp.conf.in
  • src/libpcp_import/src/GNUmakefile
  • src/libpcp_import/src/archive.c
  • src/libpcp_import/src/import.c
  • src/libpcp_import/src/libpcp_import.conf.in
  • src/libpcp_import/src/private.h
  • src/pcp/atop/GNUmakefile
  • src/pcp/atop/atop-daily.sh
  • src/pcp/atop/atop.conf
  • src/pcp/atop/atop.service.in
  • src/pmdas/pmimport/help
  • src/pmdas/pmimport/pmda_pmimport.c
  • src/selinux/GNUmakefile
  • src/selinux/import/GNUmakefile
  • src/selinux/import/pcp-import.fc
  • src/selinux/import/pcp-import.if
  • src/selinux/import/pcp-import.te
🚧 Files skipped from review as they are similar to previous changes (20)
  • src/selinux/import/pcp-import.fc
  • src/include/builddefs.in
  • qa/2007
  • src/pcp/atop/atop.conf
  • src/libpcp_import/src/private.h
  • src/include/pcp.conf.in
  • src/pcp/atop/GNUmakefile
  • src/libpcp_import/src/GNUmakefile
  • src/libpcp_import/src/import.c
  • src/pcp/atop/atop.service.in
  • src/pmdas/pmimport/pmda_pmimport.c
  • src/libpcp_import/src/libpcp_import.conf.in
  • src/libpcp_import/src/archive.c
  • qa/2005
  • configure.ac
  • src/selinux/GNUmakefile
  • src/pcp/atop/atop-daily.sh
  • src/selinux/import/pcp-import.te
  • configure
  • src/selinux/import/GNUmakefile

@natoscott

Copy link
Copy Markdown
Member Author

@coderabbitai The %{_rundir}/pmimport in redhat.spec line 2498 is correct as-is. This is the standard RPM macro for /run and matches the resolved value of @pcp_importrun_dir@ in pcp.spec.in. The redhat.spec doesn't use autoconf substitution — it uses RPM macros directly, which is the established pattern throughout that file. The suggestion to use %{_localstatedir}/run/pmimport would actually be worse (resolves to /var/run/pmimport which is a legacy compat symlink on modern systems).

All CI checks are now passing. The kernel_read_psi dummy interface, boolean dependency version guards, and AVC fixes for DSO PMDA temp files and socket access have all been folded into the single commit.

@natoscott
natoscott merged commit 3f35be6 into performancecopilot:main Jul 20, 2026
17 checks passed
@natoscott
natoscott deleted the pcp-selinux-import branch July 20, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant