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;
11
11
12
12
const ROOT_KEY_MOUNT_POINT : & str = "/bootc_authorized_ssh_keys/root" ;
13
13
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
-
18
14
fn run ( ) -> Result < ( ) > {
19
15
bootc_utils:: initialize_tracing ( ) ;
20
16
tracing:: trace!( "starting {}" , env!( "CARGO_PKG_NAME" ) ) ;
@@ -26,7 +22,7 @@ fn run() -> Result<()> {
26
22
27
23
let root_key = & prompt:: get_root_key ( ) ?;
28
24
29
- if root_key. is_none ( ) && !prompt :: ask_yes_no ( NO_SSH_PROMPT , false ) ? {
25
+ if root_key. is_none ( ) {
30
26
return Ok ( ( ) ) ;
31
27
}
32
28
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
+ } ;
2
5
use anyhow:: { ensure, Context , Result } ;
3
6
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
+
4
11
fn prompt_single_user ( user : & crate :: users:: UserKeys ) -> Result < Vec < & crate :: users:: UserKeys > > {
5
12
let prompt = format ! (
6
13
"Found only one user ({}) with {} SSH authorized keys. Would you like to install this user in the system?" ,
@@ -61,6 +68,11 @@ pub(crate) fn ask_yes_no(prompt: &str, default: bool) -> Result<bool> {
61
68
pub ( crate ) fn get_root_key ( ) -> Result < Option < UserKeys > > {
62
69
let users = get_all_users_keys ( ) ?;
63
70
if users. is_empty ( ) {
71
+ ensure ! (
72
+ prompt:: ask_yes_no( NO_SSH_PROMPT , false ) ?,
73
+ "cancelled by user"
74
+ ) ;
75
+
64
76
return Ok ( None ) ;
65
77
}
66
78
You can’t perform that action at this time.
0 commit comments