@@ -78,7 +78,6 @@ pub async fn dnixd_uds() -> color_eyre::Result<SendRequest<axum::body::Body>> {
78
78
let response = sender. send_request ( request) . await ?;
79
79
80
80
if response. status ( ) != StatusCode :: OK {
81
- tracing:: error!( "failed to connect to determinate-nixd socket" ) ;
82
81
return Err ( eyre ! ( "failed to connect to determinate-nixd socket" ) ) ;
83
82
}
84
83
@@ -90,10 +89,15 @@ impl LoginSubcommand {
90
89
let dnixd_uds = match dnixd_uds ( ) . await {
91
90
Ok ( socket) => Some ( socket) ,
92
91
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
96
95
) ;
96
+ } else {
97
+ tracing:: warn!(
98
+ "failed to connect to determinate-nixd socket, will not attempt to use it."
99
+ ) ;
100
+ }
97
101
None
98
102
}
99
103
} ;
@@ -199,8 +203,6 @@ impl LoginSubcommand {
199
203
let bytes = body. collect ( ) . await . unwrap_or_default ( ) . to_bytes ( ) ;
200
204
let text: String = String :: from_utf8_lossy ( & bytes) . into ( ) ;
201
205
202
- tracing:: trace!( "sent the add request: {:?}" , text) ;
203
-
204
206
token_updated = true ;
205
207
}
206
208
@@ -209,6 +211,11 @@ impl LoginSubcommand {
209
211
"failed to update netrc via determinatenixd, falling back to local-file approach"
210
212
) ;
211
213
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
+
212
219
update_netrc_file ( & netrc_file_path, & netrc_contents) . await ?;
213
220
214
221
// only update user_nix_config if we could not use determinatenixd
0 commit comments