@@ -483,41 +483,21 @@ pub fn home_dir() -> Option<PathBuf> {
483
483
target_os = "nacl" ,
484
484
target_os = "emscripten" ) ) ) ]
485
485
unsafe fn fallback ( ) -> Option < OsString > {
486
- #[ cfg( not( target_os = "solaris" ) ) ]
487
- unsafe fn getpwduid_r ( me : libc:: uid_t , passwd : & mut libc:: passwd ,
488
- buf : & mut Vec < c_char > ) -> Option < ( ) > {
489
- let mut result = ptr:: null_mut ( ) ;
490
- match libc:: getpwuid_r ( me, passwd, buf. as_mut_ptr ( ) ,
491
- buf. capacity ( ) ,
492
- & mut result) {
493
- 0 if !result. is_null ( ) => Some ( ( ) ) ,
494
- _ => None
495
- }
496
- }
497
-
498
- #[ cfg( target_os = "solaris" ) ]
499
- unsafe fn getpwduid_r ( me : libc:: uid_t , passwd : & mut libc:: passwd ,
500
- buf : & mut Vec < c_char > ) -> Option < ( ) > {
501
- // getpwuid_r semantics is different on Illumos/Solaris:
502
- // http://illumos.org/man/3c/getpwuid_r
503
- let result = libc:: getpwuid_r ( me, passwd, buf. as_mut_ptr ( ) ,
504
- buf. capacity ( ) ) ;
505
- if result. is_null ( ) { None } else { Some ( ( ) ) }
506
- }
507
-
508
486
let amt = match libc:: sysconf ( libc:: _SC_GETPW_R_SIZE_MAX) {
509
487
n if n < 0 => 512 as usize ,
510
488
n => n as usize ,
511
489
} ;
512
490
let mut buf = Vec :: with_capacity ( amt) ;
513
491
let mut passwd: libc:: passwd = mem:: zeroed ( ) ;
514
-
515
- if getpwduid_r ( libc:: getuid ( ) , & mut passwd, & mut buf) . is_some ( ) {
516
- let ptr = passwd. pw_dir as * const _ ;
517
- let bytes = CStr :: from_ptr ( ptr) . to_bytes ( ) . to_vec ( ) ;
518
- Some ( OsStringExt :: from_vec ( bytes) )
519
- } else {
520
- None
492
+ let mut result = ptr:: null_mut ( ) ;
493
+ match libc:: getpwuid_r ( libc:: getuid ( ) , & mut passwd, buf. as_mut_ptr ( ) ,
494
+ buf. capacity ( ) , & mut result) {
495
+ 0 if !result. is_null ( ) => {
496
+ let ptr = passwd. pw_dir as * const _ ;
497
+ let bytes = CStr :: from_ptr ( ptr) . to_bytes ( ) . to_vec ( ) ;
498
+ Some ( OsStringExt :: from_vec ( bytes) )
499
+ } ,
500
+ _ => None ,
521
501
}
522
502
}
523
503
}
0 commit comments