pmcd: restrict control metric stores to root users#2658
Conversation
Require root credentials when writing privileged pmcd control metrics to prevent unauthorized runtime configuration changes.
📝 WalkthroughSummary by CodeRabbit
WalkthroughPMCD control metrics now use named item constants, enforce nonzero-UID authorization during stores, and reset context UIDs during teardown. ChangesPMCD control authorization
Possibly related issues
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/pmdas/pmcd/src/pmcd.c (1)
34-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider utilizing these macros to replace existing magic numbers.
Defining these named constants is a great improvement. To fully realize their benefit and establish a single source of truth, consider using them to replace the hardcoded item numbers (e.g.,
item == 0,item == 4,item == 8) in the correspondingif/else ifchains further down inpmcd_storeand within theswitchstatement inpmcd_fetch.🤖 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 `@src/pmdas/pmcd/src/pmcd.c` around lines 34 - 39, Replace the hardcoded control item numbers in the conditional chains within pmcd_store and the switch in pmcd_fetch with the corresponding PMCD_CONTROL_DEBUG_ITEM, PMCD_CONTROL_TIMEOUT_ITEM, PMCD_CONTROL_REGISTER_ITEM, PMCD_CONTROL_SIGHUP_ITEM, and PMCD_CONTROL_CREDS_TIMEOUT_ITEM macros. Preserve the existing branch and case behavior while using these definitions as the single source of truth.
🤖 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.
Nitpick comments:
In `@src/pmdas/pmcd/src/pmcd.c`:
- Around line 34-39: Replace the hardcoded control item numbers in the
conditional chains within pmcd_store and the switch in pmcd_fetch with the
corresponding PMCD_CONTROL_DEBUG_ITEM, PMCD_CONTROL_TIMEOUT_ITEM,
PMCD_CONTROL_REGISTER_ITEM, PMCD_CONTROL_SIGHUP_ITEM, and
PMCD_CONTROL_CREDS_TIMEOUT_ITEM macros. Preserve the existing branch and case
behavior while using these definitions as the single source of truth.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: e3be4a26-c02e-4126-9a95-40b6f0f179f4
📒 Files selected for processing (1)
src/pmdas/pmcd/src/pmcd.c
Require root credentials when writing privileged pmcd control metrics to prevent unauthorized runtime configuration changes.
Pull Request Description
Related Issues
Fixes # #2652