@@ -78,7 +78,6 @@ pub async fn dnixd_uds() -> color_eyre::Result<SendRequest<axum::body::Body>> {
7878 let response = sender. send_request ( request) . await ?;
7979
8080 if response. status ( ) != StatusCode :: OK {
81- tracing:: error!( "failed to connect to determinate-nixd socket" ) ;
8281 return Err ( eyre ! ( "failed to connect to determinate-nixd socket" ) ) ;
8382 }
8483
@@ -90,10 +89,15 @@ impl LoginSubcommand {
9089 let dnixd_uds = match dnixd_uds ( ) . await {
9190 Ok ( socket) => Some ( socket) ,
9291 Err ( err) => {
93- tracing:: error! (
94- "failed to connect to determinate-nixd socket, will not attempt to use it: {:?}" ,
95- err
92+ if tracing:: enabled! ( tracing :: Level :: DEBUG ) {
93+ tracing :: debug! (
94+ "failed to connect to determinate-nixd socket, will not attempt to use it: {}" , err
9695 ) ;
96+ } else {
97+ tracing:: warn!(
98+ "failed to connect to determinate-nixd socket, will not attempt to use it."
99+ ) ;
100+ }
97101 None
98102 }
99103 } ;
@@ -199,8 +203,6 @@ impl LoginSubcommand {
199203 let bytes = body. collect ( ) . await . unwrap_or_default ( ) . to_bytes ( ) ;
200204 let text: String = String :: from_utf8_lossy ( & bytes) . into ( ) ;
201205
202- tracing:: trace!( "sent the add request: {:?}" , text) ;
203-
204206 token_updated = true ;
205207 }
206208
@@ -209,6 +211,11 @@ impl LoginSubcommand {
209211 "failed to update netrc via determinatenixd, falling back to local-file approach"
210212 ) ;
211213
214+ // check if user is root or not
215+ if !nix:: unistd:: Uid :: effective ( ) . is_root ( ) {
216+ return Err ( eyre ! ( "`fh login` is attempting to update a file owned by root, please re-run the same command, prefixed with `sudo -i`." ) )
217+ }
218+
212219 update_netrc_file ( & netrc_file_path, & netrc_contents) . await ?;
213220
214221 // only update user_nix_config if we could not use determinatenixd
0 commit comments