feat: offer a generated password in the first boot dialogs #27
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/inithooks!27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/generated-password"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #23.
get_password()offers a generated password. This is turnkeylinux/inithooks#71 by Marcos Mendez, as revised in #74 (typing and docstrings), with the points from the #74 review applied.Behaviour
setpass.py, 35mysqlpass throughdbpass.py(keel-mariadb), and 40wordpress throughwordpress.py(keel-wordpress). This holds on the boot run and under keel-init/turnkey-init alike, because both run the same hooks.secrets.choice(the CSPRNG). The alphabet has 59 characters,A-Z a-z 2-9without0 O o 1 l I, plus- . ~. That is about 117 bits.=is excluded because the hooks readKEY=valuewithIFS='=' read, which drops a trailing=. I checked this._is excluded becausepassword_complexity()does not count it as a symbol.-or~.password_problem(), the same checks Manual applies (pass_req, min_complexity up to 4, blacklist). Its length ismax(gen_length, pass_req), and single blacklisted characters are left out of the alphabet. If no candidate can pass (apass_reqregex), the operator is told so and gets Manual.offer_generate=Falsegives the old prompt alone.From the #74 review:
ValueError; it is not bumped."case).\Zb/\Zrattributes are used, per call, so there is no persistent--colorsand nothing to detect.Found on the real dialog
\Zcode, so #71's band showed as one reverse cell on each side. The band is now one space wider than the password.DIALOG_DEBUG),wrapper()wrote every answer to/var/log/dialog.log, typed passwords included. A password box's value is now redacted.dbpass.pyandwordpress.pyhave their stdout captured by the hook's< <(...), so on master the console showed nothing, dialog exited 3 and the wrapper looped on "Caught exception": the first boot hung in 35mysqlpass. That may be part of what #24 saw. While a widget runs, it now draws on the controlling terminal whenever stdout is not a tty. This also keeps a generated password out of the hook's pipe and out of its stderr, which is the journal.(code, value)tuple never matched ESC.#74 itself has two bugs that I did not bring in.
wrapper()checks the staleretcode(0), so ESC is never handled.menu()returnsreturn_tuple[0], which is the exit code, not the tag, so Generate could never be chosen.Tests
tests/test_dialog_wrapper.pyhas 57 tests and runs throughtests/fake_dialog.py, a scripted stand-in for pythondialog, so no terminal is needed. It covers:offer_generate=FalseKEY=valuedialog_wrapper.pyleaves the coverage omit list at 98 percent. The two misses are theDIALOG_DEBUGline at import and an inherited, unreachable branch ofget_domain. The Python total is 99 percent.Real dialog on VM1 (TurnKey 19, dialog 1.3-20250116, pythondialog 3.5.3)
These runs used
script(1), touched nothing outside/tmp/k23, and removed it afterwards.dialog.logat DEBUG had no password.psshoweddialog --file /tmp/pythondialog.tmp*(mode 0600), so the password is not in argv.dbpass.py. Generate gave the hookDB_PASSof 20 characters, with an empty stderr. Manual gaveTyped-Secret-9. The same loop against master's wrapper showed nothing and hung.Coordination with #25
This PR does not touch
run,keel-initor the lock. #25 merged while this was in progress, so master is merged into the branch (a merge commit, no force push). The three textual conflicts are resolved to keep both entries:debian/changeloghas keel11 over keel10,COVERAGE.mdhas both sections, andpyproject.tomlincludes bothdialog_wrapper.pyandinit_lock.py. With the merge, the Python suite is 359 passed and 3 skipped at 99 percent, and the bats suite passes.