Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detect noninteractive prompt when displaying warning in buildtsi #22442

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cmd/influxd/inspect/build_tsi/build_tsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,18 @@ func (buildTSICmd *buildTSI) run() error {
// Verify the user actually wants to run as root.
if isRoot() {
cli := clients.CLI{StdIO: stdio.TerminalStdio}
if confirmed := cli.StdIO.GetConfirm(`
if cli.StdIO.IsInteractive() {
if confirmed := cli.StdIO.GetConfirm(`
You are currently running as root. This will build your
index files with root ownership and will be inaccessible
if you run influxd as a non-root user. You should run
build-tsi as the same user you are running influxd.
Are you sure you want to continue?`); !confirmed {
return errors.New("operation aborted")
return errors.New("operation aborted")
}
} else {
buildTSICmd.Logger.Warn(
"You are current running as root. This will build your index files with root ownership and will be inaccessible if you run influxd as a non-root user.")
}
}

Expand Down