File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1+ [target .freebsd ]
2+ rustflags = [" -lutil" ]
3+
Original file line number Diff line number Diff line change @@ -14,3 +14,7 @@ edition = '2021'
1414# This was arbitrarily chosen on 2025-01-23 as "pretty old" as previously
1515# key didn't exist in `Cargo.toml` prior to that.
1616rust-version = ' 1.60.0'
17+
18+ [target .'cfg(target_os = "freebsd")' .dependencies ]
19+ libc = " 0.2.177"
20+
Original file line number Diff line number Diff line change @@ -53,17 +53,28 @@ pub fn candidate_cert_dirs() -> impl Iterator<Item = &'static Path> {
5353 . map ( Path :: new)
5454 . filter ( |p| p. exists ( ) )
5555}
56+
5657#[ cfg( target_os = "freebsd" ) ]
5758pub fn candidate_cert_dirs ( ) -> impl Iterator < Item = & ' static Path > {
59+ extern "C" {
60+ fn getlocalbase ( ) -> * const libc:: c_char ;
61+ }
62+ // see manpage of getlocalbase(3): https://man.freebsd.org/cgi/man.cgi?query=getlocalbase&sektion=3
63+ let localbase = unsafe {
64+ let ptr = getlocalbase ( ) ;
65+ let c_str = std:: ffi:: CStr :: from_ptr ( ptr) ;
66+ c_str. to_str ( ) . unwrap ( )
67+ } ;
68+
5869 // see manpage of certctl(8): https://man.freebsd.org/cgi/man.cgi?query=certctl&sektion=8
5970 // see security/openssl* ports
6071 [
61- "/etc/ssl" ,
62- "/usr/local/ etc/ssl",
63- "/usr/local/ openssl",
72+ "/etc/ssl" . to_string ( ) ,
73+ format ! ( "{}/ etc/ssl", localbase ) ,
74+ format ! ( "{}/ openssl", localbase ) ,
6475 ]
65- . iter ( )
66- . map ( Path :: new)
76+ . into_iter ( )
77+ . map ( |s| Path :: new ( Box :: leak ( Box :: new ( s ) ) ) )
6778 . filter ( |p| p. exists ( ) )
6879}
6980
You can’t perform that action at this time.
0 commit comments