1- use std:: process:: Command ;
1+ use std:: process:: { Command , Stdio } ;
22use std:: {
33 collections:: HashSet ,
44 fs:: { File , Permissions } ,
@@ -21,8 +21,6 @@ use fdo_data_formats::{
2121} ;
2222use fdo_http_wrapper:: client:: { RequestResult , ServiceClient } ;
2323
24- use sha_crypt:: { sha256_check, sha256_simple, Sha256Params } ;
25-
2624const MAX_SERVICE_INFO_LOOPS : u32 = 1000 ;
2725
2826fn find_available_modules ( ) -> Result < Vec < ServiceInfoModule > > {
@@ -111,9 +109,24 @@ fn create_user_with_password(user: &str, password: &str) -> Result<()> {
111109 log:: info!( "Checking for password encryption" ) ;
112110 if !is_password_encrypted ( password) {
113111 log:: info!( "Encrypting password" ) ;
114- let default_params: Sha256Params = Default :: default ( ) ;
115- str_encrypted_pw = sha256_simple ( password, & default_params) . expect ( "Hashing failed" ) ;
116- assert ! ( sha256_check( password, & str_encrypted_pw) . is_ok( ) ) ;
112+ let echo = Command :: new ( "echo" )
113+ . arg ( password)
114+ . stdout ( Stdio :: piped ( ) )
115+ . spawn ( )
116+ . expect ( "Error spawning echo" ) ;
117+ let hasher = Command :: new ( "openssl" )
118+ . arg ( "passwd" )
119+ . arg ( "-6" )
120+ . arg ( "-stdin" )
121+ . stdin ( Stdio :: from (
122+ echo. stdout . expect ( "Error getting stdout from echo" ) ,
123+ ) )
124+ . output ( )
125+ . expect ( "Error getting output of openssl" ) ;
126+ str_encrypted_pw = str:: from_utf8 ( & hasher. stdout )
127+ . expect ( "Error converting [u8] to string" )
128+ . trim_end ( )
129+ . to_string ( ) ;
117130 }
118131 // Creates new user if user not present
119132 log:: info!( "Creating user {user} with password" ) ;
0 commit comments