mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-11-05 18:57:42 +00:00
feat(seed): read the database password from stdin with --password-stdin
baudolo-seed took the database password only as a positional argument, so it showed in the process list of the host that seeds the backup catalog (infinito-nexus/core #1213). --password-stdin reads it from stdin without the trailing newline. The positional argument still works for existing callers but warns on stderr that it is visible in the process list; giving the password both ways, or neither, is rejected with a usage error and writes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4214d3709a
commit
5817078643
3 files changed
+106
-2
No files matched your search
@@ -73,9 +73,30 @@ def main() -> None:
|
||||
help="Database name or '*' to dump all databases",
|
||||
)
|
||||
parser.add_argument("username", help="Database username")
|
||||
parser.add_argument("password", help="Database password")
|
||||
parser.add_argument(
|
||||
"password",
|
||||
nargs="?",
|
||||
help="Deprecated: database password as an argument, visible in the "
|
||||
"process list; use --password-stdin",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--password-stdin",
|
||||
action="store_true",
|
||||
help="Read the database password from stdin",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.password_stdin == (args.password is not None):
|
||||
parser.error("give the password either via --password-stdin or as an argument")
|
||||
if args.password_stdin:
|
||||
password = sys.stdin.read().removesuffix("\n")
|
||||
else:
|
||||
print(
|
||||
"WARNING: a password argument is visible in the process list; "
|
||||
"use --password-stdin",
|
||||
file=sys.stderr,
|
||||
)
|
||||
password = args.password
|
||||
|
||||
try:
|
||||
check_and_add_entry(
|
||||
@@ -83,7 +104,7 @@ def main() -> None:
|
||||
instance=args.instance,
|
||||
database=args.database,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
password=password,
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001 - CLI boundary: any failure becomes exit 1
|
||||
print(f"ERROR: {exc}", file=sys.stderr)
|
||||
|
||||
Reference in new issue
Block a user