--cmd is silently ignored unless --enter is also set #1

Closed
opened 2026-07-25 11:24:36 +00:00 by AnmiTaliDev · 0 comments
AnmiTaliDev commented 2026-07-25 11:24:36 +00:00 (Migrated from github.com)

Description

The --cmd flag is meant to specify the command to run inside the chroot, but it only takes effect when --enter is also passed.

// main.go:178
if enter && cmdStr != "" {
    cmdArgs = []string{"/bin/sh", "-c", cmdStr}
    logDebug("Custom command set via -cmd: %s", cmdStr)
}

If a user runs the program with --cmd="whoami" but without --enter, the cmdStr value is silently dropped, and the default command (/bin/sh) or positional args are executed instead.

Steps to reproduce

./warproot --userspec=1000 --cmd="id" /path/to/root

Expected: id runs inside the chroot.
Actual: /bin/sh runs instead; --cmd is ignored with no warning printed or logged.

Expected behavior

--cmd should take effect regardless of --enter, or — if this coupling is intentional — the program should explicitly warn the user that --cmd has no effect without --enter.

Additional notes

The --enter flag isn't used anywhere else in the code apart from this check — looks like unfinished/leftover logic.

### Description The `--cmd` flag is meant to specify the command to run inside the chroot, but it only takes effect when `--enter` is also passed. ```go // main.go:178 if enter && cmdStr != "" { cmdArgs = []string{"/bin/sh", "-c", cmdStr} logDebug("Custom command set via -cmd: %s", cmdStr) } ``` If a user runs the program with `--cmd="whoami"` but without `--enter`, the `cmdStr` value is silently dropped, and the default command (`/bin/sh`) or positional args are executed instead. ### Steps to reproduce ``` ./warproot --userspec=1000 --cmd="id" /path/to/root ``` Expected: `id` runs inside the chroot. Actual: `/bin/sh` runs instead; `--cmd` is ignored with no warning printed or logged. ### Expected behavior `--cmd` should take effect regardless of `--enter`, or — if this coupling is intentional — the program should explicitly warn the user that `--cmd` has no effect without `--enter`. ### Additional notes The `--enter` flag isn't used anywhere else in the code apart from this check — looks like unfinished/leftover logic.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
utils/warproot#1
No description provided.