[PR #12] [MERGED] fix: skip sudo when already running as root #20

Closed
opened 2026-02-15 17:17:15 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/openclaw.ai/pull/12
Author: @Glucksberg
Created: 1/25/2026
Status: Merged
Merged: 1/27/2026
Merged by: @thewilloftheshadow

Base: mainHead: fix/sudo-when-root


📝 Commits (2)

  • 9c50f08 fix: skip sudo when already running as root
  • 91b197e fix: note sudo handling in installer (#12) (thanks @Glucksberg)

📊 Changes

2 files changed (+24 additions, -10 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 public/install.sh (+23 -10)

📄 Description

Summary

When running the install script as root (e.g., in a minimal container or VM), the script fails if the sudo binary isn't installed, even though sudo isn't needed when already running as root.

Changes:

  • Add a maybe_sudo() helper function that runs commands directly when already root
  • Only uses sudo when running as a normal user
  • Handles the -E flag (preserve environment) correctly in both cases

Fixes clawdbot/clawdbot#1933

Test plan

  • Test install script as non-root user with sudo available (unchanged behavior)
  • Test install script as root user without sudo binary installed (should work now)
  • Test install script as root user with sudo binary installed (should work)

Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/openclaw.ai/pull/12 **Author:** [@Glucksberg](https://github.com/Glucksberg) **Created:** 1/25/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@thewilloftheshadow](https://github.com/thewilloftheshadow) **Base:** `main` ← **Head:** `fix/sudo-when-root` --- ### 📝 Commits (2) - [`9c50f08`](https://github.com/openclaw/openclaw.ai/commit/9c50f087b103919ea155865b9e17f0a9e8d7c019) fix: skip sudo when already running as root - [`91b197e`](https://github.com/openclaw/openclaw.ai/commit/91b197eda7647ca3c99dc99a7395c6f85806796f) fix: note sudo handling in installer (#12) (thanks @Glucksberg) ### 📊 Changes **2 files changed** (+24 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `public/install.sh` (+23 -10) </details> ### 📄 Description ## Summary When running the install script as root (e.g., in a minimal container or VM), the script fails if the `sudo` binary isn't installed, even though sudo isn't needed when already running as root. **Changes:** - Add a `maybe_sudo()` helper function that runs commands directly when already root - Only uses `sudo` when running as a normal user - Handles the `-E` flag (preserve environment) correctly in both cases Fixes clawdbot/clawdbot#1933 ## Test plan - [ ] Test install script as non-root user with sudo available (unchanged behavior) - [ ] Test install script as root user without sudo binary installed (should work now) - [ ] Test install script as root user with sudo binary installed (should work) --- Generated with [Claude Code](https://claude.ai/code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:17:15 -05:00
yindo closed this issue 2026-02-15 17:17:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/openclaw.ai#20