RPM native build updates #2253
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2253
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2253/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #1674
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1674
Original created: 2025-09-29T19:29:57Z
Original updated: 2025-09-30T02:12:46Z
Original head: carverauto/serviceradar:bug/core_rpm_installer_homedir
Original base: main
Original merged: 2025-09-30T02:10:49Z by @mfreeman451
PR Type
Enhancement
Description
Switch to native RPM builds on Oracle Linux/RHEL
Standardize user management with managed home directories
Update packaging file paths for consistency
Add dedicated web component build script
Diagram Walkthrough
File Walkthrough
22 files
Add native web RPM build scriptSwitch to native RPM buildsStandardize user management and pathsUpdate user creation with home directoryAdd dependencies and logging configurationUpdate paths and user managementUpdate paths and user creationStandardize user management approachUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate user management and pathsUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creationUpdate paths and user creation3 files
Fix packaging file pathsFix packaging file pathsFix packaging file pathsImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1674#issuecomment-3348727914
Original created: 2025-09-29T19:30:38Z
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
Privilege escalation and capabilities:
Multiple spec %post scripts and build scripts use sudo, setcap, and create system users/dirs. Ensure setcap usage in serviceradar-agent (%post) grants only necessary capabilities and handles absence of sudo (RPM scripts run as root; sudo is not needed and may fail). Also confirm permissions on /var/lib/serviceradar (0750) and log dirs prevent unauthorized access while allowing required service read/write.
Robustness
Several shell commands assume sudo, network access, and writable HOME without error handling (e.g., dnf installs, rpmdev-setuptree, npm install/build). Consider explicit checks/fail-fast messages, and handling non-interactive sudo or missing permissions. Also, writing build-info.json assumes public dir exists.
OS Detection
Grepping /etc/os-release for multiple distros may mis-detect or miss variants; rely on ID/ID_LIKE keys for more reliable native RPM build gating. Validate behavior on non-RHEL-like systems.
Post Script Changes
The %post section now creates directories and runs an inline Python script to mutate config. Verify python3 is present at runtime, SELinux/file contexts, and that config edits don't overwrite admin changes unintentionally.
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1674#issuecomment-3348735131
Original created: 2025-09-29T19:32:28Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Consolidate user management into a common package
The user and group creation logic for 'serviceradar' is duplicated across
numerous RPM spec files. This should be consolidated into a single, common base
package that other packages can depend on to improve maintainability.
Examples:
packaging/specs/serviceradar-agent.spec [36-52]
packaging/specs/serviceradar-core.spec [54-70]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies widespread logic duplication for user creation across many RPM spec files and proposes a standard, more maintainable architectural solution.
Add proper error handling
Improve the embedded Python script by adding specific error handling for file
I/O and JSON parsing. This will prevent silent failures and ensure the system
remains in a consistent state.
packaging/specs/serviceradar-core.spec [176-210]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a lack of robust error handling in the embedded Python script, which could cause silent failures during package installation. The proposed changes make the script more resilient and provide better diagnostics, which is important for package management scripts.
Add package manager detection
Make the script compatible with more systems by checking for
dnfand fallingback to
yumifdnfis not available. This avoids failures on older distributionsthat use
yum.scripts/setup-package.sh [543]
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly points out that hardcoding
dnflimits the script's compatibility with older RHEL/CentOS systems that useyum. Adding a fallback toyumimproves the script's portability and robustness.Add package manager compatibility
Improve package manager compatibility by checking for
dnfand falling back toyumif it's not present. This allows the script to run on a wider range ofRHEL-based distributions.
scripts/build-web-rpm.sh [35-44]
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies that hardcoding
dnflimits the script's portability to RHEL/CentOS versions that useyum. The proposed change to support bothdnfandyummakes the build script more robust and compatible across different environments.Optimize OS detection logic
Refactor the OS detection logic to avoid calling
greptwice on/etc/os-release.Add a fallback to handle cases where
PRETTY_NAMEis not found.scripts/setup-package.sh [526-527]
Suggestion importance[1-10]: 2
__
Why: The suggestion's primary claim of inefficiency is negligible, and the proposed code still calls
greptwice. The only minor improvement is adding a fallback forPRETTY_NAME, which slightly increases robustness but does not address the stated problem.