File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
system-reinstall-bootc/src Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ pub(crate) mod users;
1111
1212const ROOT_KEY_MOUNT_POINT : & str = "/bootc_authorized_ssh_keys/root" ;
1313
14- const NO_SSH_PROMPT : & str = "None of the users on this system found have authorized SSH keys, if
15- your image doesn't use cloud-init or other means to set up users, you may not be able to log in
16- after reinstalling. Do you want to continue?" ;
17-
1814fn run ( ) -> Result < ( ) > {
1915 bootc_utils:: initialize_tracing ( ) ;
2016 tracing:: trace!( "starting {}" , env!( "CARGO_PKG_NAME" ) ) ;
@@ -26,7 +22,7 @@ fn run() -> Result<()> {
2622
2723 let root_key = & prompt:: get_root_key ( ) ?;
2824
29- if root_key. is_none ( ) && !prompt :: ask_yes_no ( NO_SSH_PROMPT , false ) ? {
25+ if root_key. is_none ( ) {
3026 return Ok ( ( ) ) ;
3127 }
3228
Original file line number Diff line number Diff line change 1- use crate :: users:: { get_all_users_keys, UserKeys } ;
1+ use crate :: {
2+ prompt,
3+ users:: { get_all_users_keys, UserKeys } ,
4+ } ;
25use anyhow:: { ensure, Context , Result } ;
36
7+ const NO_SSH_PROMPT : & str = "None of the users on this system found have authorized SSH keys, \
8+ if your image doesn't use cloud-init or other means to set up users, \
9+ you may not be able to log in after reinstalling. Do you want to continue?";
10+
411fn prompt_single_user ( user : & crate :: users:: UserKeys ) -> Result < Vec < & crate :: users:: UserKeys > > {
512 let prompt = format ! (
613 "Found only one user ({}) with {} SSH authorized keys. Would you like to import it and its keys to the system?" ,
@@ -61,6 +68,11 @@ pub(crate) fn ask_yes_no(prompt: &str, default: bool) -> Result<bool> {
6168pub ( crate ) fn get_root_key ( ) -> Result < Option < UserKeys > > {
6269 let users = get_all_users_keys ( ) ?;
6370 if users. is_empty ( ) {
71+ ensure ! (
72+ prompt:: ask_yes_no( NO_SSH_PROMPT , false ) ?,
73+ "cancelled by user"
74+ ) ;
75+
6476 return Ok ( None ) ;
6577 }
6678
You can’t perform that action at this time.
0 commit comments