@@ -21,18 +21,14 @@ def setup_auth(
2121 self ,
2222 install_session : 'Installer' ,
2323 auth_config : AuthenticationConfiguration ,
24- users : list ['User' ] | None = None ,
24+ users : list ['User' ],
25+ hostname : str ,
2526 ) -> None :
2627 if auth_config .u2f_config and users is not None :
27- self ._setup_u2f_login (install_session , auth_config .u2f_config , users )
28+ self ._setup_u2f_login (install_session , auth_config .u2f_config , users , hostname )
2829
29- def _setup_u2f_login (
30- self ,
31- install_session : 'Installer' ,
32- u2f_config : U2FLoginConfiguration ,
33- users : list [User ],
34- ) -> None :
35- self ._configure_u2f_mapping (install_session , u2f_config , users )
30+ def _setup_u2f_login (self , install_session : 'Installer' , u2f_config : U2FLoginConfiguration , users : list [User ], hostname : str ) -> None :
31+ self ._configure_u2f_mapping (install_session , u2f_config , users , hostname )
3632 self ._update_pam_config (install_session , u2f_config )
3733
3834 def _update_pam_config (
@@ -42,9 +38,9 @@ def _update_pam_config(
4238 ) -> None :
4339 match u2f_config .u2f_login_method :
4440 case U2FLoginMethod .Passwordless :
45- config_entry = f 'auth sufficient pam_u2f.so authfile={ self . _u2f_auth_file } cue'
41+ config_entry = 'auth sufficient pam_u2f.so authfile=/etc/u2f_mappings cue'
4642 case U2FLoginMethod .SecondFactor :
47- config_entry = f 'auth required pam_u2f.so authfile={ self . _u2f_auth_file } cue'
43+ config_entry = 'auth required pam_u2f.so authfile=/etc/u2f_mappings cue'
4844 case _:
4945 raise ValueError (f'Unknown U2F login method: { u2f_config .u2f_login_method } ' )
5046
@@ -79,15 +75,21 @@ def _add_u2f_entry(self, file: Path, entry: str) -> None:
7975
8076 file .write_text ('\n ' .join (content ) + '\n ' )
8177
82- def _configure_u2f_mapping (self , install_session : 'Installer' , u2f_config : U2FLoginConfiguration , users : list [User ]) -> None :
78+ def _configure_u2f_mapping (
79+ self ,
80+ install_session : 'Installer' ,
81+ u2f_config : U2FLoginConfiguration ,
82+ users : list [User ],
83+ hostname : str ,
84+ ) -> None :
8385 debug (f'Setting up U2F login: { u2f_config .u2f_login_method .value } ' )
8486
8587 install_session .pacman .strap ('pam-u2f' )
8688
8789 Tui .print (tr (f'Setting up U2F login: { u2f_config .u2f_login_method .value } ' ))
8890
8991 # https://developers.yubico.com/pam-u2f/
90- u2f_auth_file = install_session .target / self . _u2f_auth_file
92+ u2f_auth_file = install_session .target / 'etc/u2f_mappings'
9193 u2f_auth_file .touch ()
9294 existing_keys = u2f_auth_file .read_text ()
9395
@@ -98,7 +100,11 @@ def _configure_u2f_mapping(self, install_session: 'Installer', u2f_config: U2FLo
98100 Tui .print (tr ('Setting up U2F device for user: {}' ).format (user .username ))
99101 Tui .print (tr ('You may need to enter the PIN and then touch your U2F device to register it' ))
100102
101- worker = SysCommandWorker (f'arch-chroot { install_session .target } pamu2fcfg -u { user .username } ' , peek_output = True )
103+ cmd = ' ' .join (['arch-chroot' , str (install_session .target ), 'pamu2fcfg' , '-u' , user .username , '-o' , f'pam://{ hostname } ' , '-i' , f'pam://{ hostname } ' ])
104+
105+ debug (f'Enrolling U2F device: { cmd } ' )
106+
107+ worker = SysCommandWorker (cmd , peek_output = True )
102108 pin_inputted = False
103109
104110 while worker .is_alive ():
0 commit comments