forked from Mirror/pmbootstrap
pmb.config: use ssh_key_glob for ask_for_ssh_keys (MR 2251)
Since a user can modify the glob to be somewhat arbitrary, use that to check if any ssh keys exist and ask in pmbootstrap init. Otherwise ssh_key_glob would only work if it was a subset of ~/.ssh/id_*.pub, so e.g. ~/.ssh/id_foo.pub but ~/.ssh/foo.pub wouldn't work.
This commit is contained in:
parent
d19de946b3
commit
ca9610a153
1 changed files with 3 additions and 3 deletions
|
@ -645,8 +645,8 @@ def ask_for_hostname(default: str | None, device: str) -> str:
|
|||
return ret
|
||||
|
||||
|
||||
def ask_for_ssh_keys(default: bool) -> bool:
|
||||
if not len(glob.glob(os.path.expanduser("~/.ssh/id_*.pub"))):
|
||||
def ask_for_ssh_keys(ssh_key_glob: str, default: bool) -> bool:
|
||||
if not len(glob.glob(os.path.expanduser(ssh_key_glob))):
|
||||
return False
|
||||
return pmb.helpers.cli.confirm(
|
||||
"Would you like to copy your SSH public keys to the device?", default=default
|
||||
|
@ -787,7 +787,7 @@ def frontend(args: PmbArgs) -> None:
|
|||
config.hostname = ask_for_hostname(config.hostname, device)
|
||||
|
||||
# SSH keys
|
||||
config.ssh_keys = ask_for_ssh_keys(config.ssh_keys)
|
||||
config.ssh_keys = ask_for_ssh_keys(config.ssh_key_glob, config.ssh_keys)
|
||||
|
||||
# pmaports path (if users change it with: 'pmbootstrap --aports=... init')
|
||||
config.aports = get_context().config.aports
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue