This repository was archived by the owner on Oct 25, 2026. It is now read-only.
Repository navigation
Conversation
Since #3402, parseEnv() runs before parseOptions() so command line arguments override environment variables. The password warning at the end of parseOptions() checks only that auth is non-NULL, so a password from VALKEYCLI_AUTH or REDISCLI_AUTH now prints "Using a password with '-a' or '-u' option on the command line interface may not be safe", even though no password was on the command line. Remember the auth value parseEnv() left behind and warn only when parseOptions() replaced it. -a and -u still warn and still override the environment variable. Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #3402,
valkey-clireads environment variables before it parses command line options, so options can override them. The "Using a password with '-a' or '-u' option on the command line interface may not be safe" warning only checks that a password is set, so a password fromVALKEYCLI_AUTHorREDISCLI_AUTHalone now prints it, even though nothing was on the command line. The fix warns only when-aor-ureplaced the password the environment provided.-astill warns and still overrides the environment variable.AI generated details
Problem
Based on upstream unstable
8f67ab136, so the base branch here isupstream-unstable-8f67ab136. Line numbers are at that commit.baa5a48 (#3402) moved
parseEnv()ahead ofparseOptions()inmain()(src/valkey-cli.c:10165) so that-h/-poverrideVALKEYCLI_HOST/VALKEYCLI_PORT.parseEnv()now writesVALKEYCLI_AUTHintoconfig.conn_info.authfirst (src/valkey-cli.c:2942), and the warning at the end ofparseOptions()fires on any non-NULL password (src/valkey-cli.c:2906):Before #3402 the order was reversed, so
authwas still NULL at that check unless-aor-uhad set it. Affects 9.2.0-rc1. 9.1.x and earlier runparseEnv()afterparseOptions().Fix
parseOptions()records theauthpointer it starts with, which is whateverparseEnv()set, and warns only if the pointer changed.-aand-uwith a password always allocate a new sds (src/valkey-cli.c:2620,src/cli_common.c:359), so they still warn.--askpassruns afterparseOptions()and never warned. TheparseEnv()ordering is unchanged, so command line options still override every environment variable.VALKEYCLI_AUTHonlyREDISCLI_AUTHonly-uwithout password, plusVALKEYCLI_AUTH-aonly-uwith passwordVALKEYCLI_AUTH, right-a-aused-aused-ausedVALKEYCLI_AUTHwith--no-auth-warningThe "before #3402" column is from a build of baa5a48^.
Alternative considered
Moving the auth part of
parseEnv()back afterparseOptions()with the oldauth == NULLguard would also work, but it splitsparseEnv()and puts auth on a different precedence path from user, host, and port. Comparing the pointer leaves #3402's ordering alone.Testing
The existing tests missed it because they don't check stderr:
run_clireads only stdout, and theVALKEYCLI_USERtest passes--no-auth-warning. The new test merges stderr into the result. It also checks that-astill warns and still overrides a wrongVALKEYCLI_AUTH.With the test in the tree and
src/valkey-cli.creverted to the base:Not run locally with
--tls. The TLS test harness is broken on the machine this was written on, for every test file and not just this one.This was generated by AI but verified, with love, by a human.