diff --git a/Cargo.lock b/Cargo.lock
index 13fdbfef2a9d1..83af5107d1b22 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -142,7 +142,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
"synstructure",
]
@@ -154,7 +154,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -184,7 +184,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -279,7 +279,7 @@ dependencies = [
"regex",
"rustc-hash",
"shlex",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -301,7 +301,7 @@ dependencies = [
"regex",
"rustc-hash",
"shlex",
- "syn 2.0.68",
+ "syn",
"which",
]
@@ -417,7 +417,7 @@ dependencies = [
"quote",
"serde",
"serde_json",
- "syn 2.0.68",
+ "syn",
"tempfile",
"toml",
]
@@ -448,12 +448,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-[[package]]
-name = "cfg_aliases"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
-
[[package]]
name = "cipher"
version = "0.4.4"
@@ -639,7 +633,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -685,7 +679,7 @@ checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -726,7 +720,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -892,7 +886,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -988,7 +982,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -1283,15 +1277,6 @@ dependencies = [
"generic-array",
]
-[[package]]
-name = "instant"
-version = "0.1.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
-dependencies = [
- "cfg-if",
-]
-
[[package]]
name = "ipnet"
version = "2.9.0"
@@ -1743,7 +1728,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -1856,17 +1841,6 @@ dependencies = [
"sha2",
]
-[[package]]
-name = "parking_lot"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
-dependencies = [
- "instant",
- "lock_api",
- "parking_lot_core 0.8.6",
-]
-
[[package]]
name = "parking_lot"
version = "0.12.3"
@@ -1874,21 +1848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
- "parking_lot_core 0.9.10",
-]
-
-[[package]]
-name = "parking_lot_core"
-version = "0.8.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
-dependencies = [
- "cfg-if",
- "instant",
- "libc",
- "redox_syscall 0.2.16",
- "smallvec",
- "winapi",
+ "parking_lot_core",
]
[[package]]
@@ -1899,7 +1859,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
- "redox_syscall 0.5.2",
+ "redox_syscall",
"smallvec",
"windows-targets 0.52.6",
]
@@ -2064,7 +2024,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -2146,7 +2106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
dependencies = [
"proc-macro2",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -2245,7 +2205,7 @@ dependencies = [
"iso7816",
"iso7816-tlv",
"log",
- "parking_lot 0.12.3",
+ "parking_lot",
"picky",
"picky-asn1-der",
"picky-asn1-x509",
@@ -2255,7 +2215,6 @@ dependencies = [
"rsa",
"rustls",
"sspi",
- "static_init",
"tempfile",
"tokio",
"tokio-boring",
@@ -2264,15 +2223,6 @@ dependencies = [
"uuid",
]
-[[package]]
-name = "redox_syscall"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
-dependencies = [
- "bitflags 1.3.2",
-]
-
[[package]]
name = "redox_syscall"
version = "0.5.2"
@@ -2588,7 +2538,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -2786,34 +2736,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
-[[package]]
-name = "static_init"
-version = "1.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6"
-dependencies = [
- "bitflags 1.3.2",
- "cfg_aliases",
- "libc",
- "parking_lot 0.11.2",
- "parking_lot_core 0.8.6",
- "static_init_macro",
- "winapi",
-]
-
-[[package]]
-name = "static_init_macro"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf"
-dependencies = [
- "cfg_aliases",
- "memchr",
- "proc-macro2",
- "quote",
- "syn 1.0.109",
-]
-
[[package]]
name = "strsim"
version = "0.11.1"
@@ -2826,17 +2748,6 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
-[[package]]
-name = "syn"
-version = "1.0.109"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
-]
-
[[package]]
name = "syn"
version = "2.0.68"
@@ -2865,7 +2776,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -2904,7 +2815,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -2982,7 +2893,7 @@ checksum = "8d9ef545650e79f30233c0003bcc2504d7efac6dad25fca40744de773fe2049c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -2995,7 +2906,7 @@ dependencies = [
"bytes",
"libc",
"mio",
- "parking_lot 0.12.3",
+ "parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
@@ -3022,7 +2933,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -3117,7 +3028,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -3303,7 +3214,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
"wasm-bindgen-shared",
]
@@ -3337,7 +3248,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -3429,7 +3340,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -3440,7 +3351,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -3690,5 +3601,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
diff --git a/lib/srv/desktop/rdp/rdpclient/Cargo.toml b/lib/srv/desktop/rdp/rdpclient/Cargo.toml
index 0e0a43e2ad449..dddebf776c73c 100644
--- a/lib/srv/desktop/rdp/rdpclient/Cargo.toml
+++ b/lib/srv/desktop/rdp/rdpclient/Cargo.toml
@@ -33,7 +33,6 @@ rand = { version = "0.8.5", features = ["getrandom"] }
rand_chacha = "0.3.1"
rsa = "0.9.6"
sspi = { version = "0.13.0", features = ["network_client"] }
-static_init = "1.0.3"
tokio = { version = "1.40", features = ["full"] }
tokio-boring = { git = "https://github.com/gravitational/boring", rev="99897308abb5976ea05625b8314c24b16eebb01b", optional = true }
utf16string = "0.2.0"
diff --git a/lib/srv/desktop/rdp/rdpclient/client.go b/lib/srv/desktop/rdp/rdpclient/client.go
index 5b8a48a7eb9e5..1642f6a3368b3 100644
--- a/lib/srv/desktop/rdp/rdpclient/client.go
+++ b/lib/srv/desktop/rdp/rdpclient/client.go
@@ -118,7 +118,7 @@ func init() {
os.Setenv("RUST_LOG", rustLogLevel)
}
- C.init()
+ C.rdpclient_init_log()
}
// Client is the RDP client.
@@ -1042,7 +1042,6 @@ func (c *Client) sharedDirectoryMoveRequest(req tdp.SharedDirectoryMoveRequest)
return C.ErrCodeFailure
}
return C.ErrCodeSuccess
-
}
//export cgo_tdp_sd_truncate_request
@@ -1069,7 +1068,6 @@ func (c *Client) sharedDirectoryTruncateRequest(req tdp.SharedDirectoryTruncateR
return C.ErrCodeFailure
}
return C.ErrCodeSuccess
-
}
// GetClientLastActive returns the time of the last recorded activity.
diff --git a/lib/srv/desktop/rdp/rdpclient/client_fips.go b/lib/srv/desktop/rdp/rdpclient/client_fips.go
new file mode 100644
index 0000000000000..d1c120db1cf78
--- /dev/null
+++ b/lib/srv/desktop/rdp/rdpclient/client_fips.go
@@ -0,0 +1,28 @@
+//go:build desktop_access_rdp && fips
+
+// Teleport
+// Copyright (C) 2024 Gravitational, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package rdpclient
+
+/*
+#include
+*/
+import "C"
+
+func init() {
+ C.rdpclient_assert_fips_enabled()
+}
diff --git a/lib/srv/desktop/rdp/rdpclient/src/client/global.rs b/lib/srv/desktop/rdp/rdpclient/src/client/global.rs
index 65051237d7670..088174878b269 100644
--- a/lib/srv/desktop/rdp/rdpclient/src/client/global.rs
+++ b/lib/srv/desktop/rdp/rdpclient/src/client/global.rs
@@ -36,8 +36,7 @@
use super::ClientHandle;
use crate::CgoHandle;
use parking_lot::RwLock;
-use static_init::dynamic;
-use std::collections::HashMap;
+use std::{collections::HashMap, sync::LazyLock};
/// Gets a [`ClientHandle`] from the global [`CLIENT_HANDLES`] map.
pub fn get_client_handle(cgo_handle: CgoHandle) -> Option {
@@ -45,14 +44,13 @@ pub fn get_client_handle(cgo_handle: CgoHandle) -> Option {
}
/// A global, static tokio runtime for use by all clients.
-#[dynamic]
-pub static TOKIO_RT: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap();
+pub static TOKIO_RT: LazyLock =
+ LazyLock::new(|| tokio::runtime::Runtime::new().unwrap());
/// A global, static map of [`ClientHandle`] indexed by [`CgoHandle`].
///
/// See [`ClientHandles`].
-#[dynamic]
-pub static CLIENT_HANDLES: ClientHandles = ClientHandles::new();
+pub static CLIENT_HANDLES: LazyLock = LazyLock::new(Default::default);
const _: () = {
/// References to following types can be shared by multiple
@@ -69,15 +67,14 @@ const _: () = {
/// A function can be dispatched to the [`Client`] corresponding to a
/// given [`CgoHandle`] by retrieving it's corresponding [`ClientHandle`]
/// from this map and sending the desired [`ClientFunction`].
+#[derive(Default)]
pub struct ClientHandles {
map: RwLock>,
}
impl ClientHandles {
- fn new() -> Self {
- ClientHandles {
- map: RwLock::new(HashMap::new()),
- }
+ pub fn new() -> Self {
+ Default::default()
}
pub fn insert(&self, cgo_handle: CgoHandle, client_handle: ClientHandle) {
diff --git a/lib/srv/desktop/rdp/rdpclient/src/cliprdr.rs b/lib/srv/desktop/rdp/rdpclient/src/cliprdr.rs
index 26d750d00f81e..9d7e2b699af1c 100644
--- a/lib/srv/desktop/rdp/rdpclient/src/cliprdr.rs
+++ b/lib/srv/desktop/rdp/rdpclient/src/cliprdr.rs
@@ -25,14 +25,10 @@ use ironrdp_cliprdr::{Client, CliprdrClient as Cliprdr, CliprdrSvcMessages};
use ironrdp_pdu::PduResult;
use ironrdp_svc::impl_as_any;
use log::{debug, error, info, trace, warn};
-use static_init::dynamic;
use std::fmt::{Debug, Formatter};
-#[dynamic]
-static CF_UNICODETEXT: ClipboardFormat = ClipboardFormat::new(ClipboardFormatId::CF_UNICODETEXT);
-
-#[dynamic]
-static CF_TEXT: ClipboardFormat = ClipboardFormat::new(ClipboardFormatId::CF_TEXT);
+const CF_UNICODETEXT: ClipboardFormat = ClipboardFormat::new(ClipboardFormatId::CF_UNICODETEXT);
+const CF_TEXT: ClipboardFormat = ClipboardFormat::new(ClipboardFormatId::CF_TEXT);
#[derive(Debug)]
pub struct TeleportCliprdrBackend {
@@ -238,9 +234,9 @@ where
pub fn available_formats(data: &Option) -> Vec {
if let Some(s) = data {
- let mut formats = vec![CF_UNICODETEXT.to_owned()];
+ let mut formats = vec![CF_UNICODETEXT];
if s.is_ascii() {
- formats.push(CF_TEXT.to_owned())
+ formats.push(CF_TEXT)
}
return formats;
}
diff --git a/lib/srv/desktop/rdp/rdpclient/src/lib.rs b/lib/srv/desktop/rdp/rdpclient/src/lib.rs
index 05b16ca8fe6ac..8b2ffb902a339 100644
--- a/lib/srv/desktop/rdp/rdpclient/src/lib.rs
+++ b/lib/srv/desktop/rdp/rdpclient/src/lib.rs
@@ -49,9 +49,13 @@ mod rdpdr;
mod ssl;
mod util;
+/// rdpclient_init_log should be called at initialization time to set up
+/// logging on the rdpclient side.
#[no_mangle]
-pub extern "C" fn init() {
- env_logger::try_init().unwrap_or_else(|e| println!("failed to initialize Rust logger: {e}"));
+pub extern "C" fn rdpclient_init_log() {
+ if let Err(e) = env_logger::try_init() {
+ eprintln!("failed to initialize Rust logger: {e}");
+ }
}
/// free_string is used to free memory for strings that were passed back to Go side.
diff --git a/lib/srv/desktop/rdp/rdpclient/src/ssl.rs b/lib/srv/desktop/rdp/rdpclient/src/ssl.rs
index 928aa1aeb5e31..6f226f4065b0c 100644
--- a/lib/srv/desktop/rdp/rdpclient/src/ssl.rs
+++ b/lib/srv/desktop/rdp/rdpclient/src/ssl.rs
@@ -15,22 +15,17 @@
// along with this program. If not, see .
use crate::client::{ClientError, ClientResult};
-#[cfg(feature = "fips")]
-use static_init::dynamic;
use tokio::net::TcpStream;
#[cfg(feature = "fips")]
pub type TlsStream = tokio_boring::SslStream;
+// rdpclient_assert_fips_enabled asserts that FIPS is compiled in and enabled.
#[cfg(feature = "fips")]
-#[dynamic(0)]
-static mut FIPS_CHECK: () = unsafe {
- // Make sure that we really have FIPS enabled.
- // This assert will run at the start of the program and panic if we
- // build for FIPS but it's somehow disabled
- use boring;
- assert!(boring::fips::enabled(), "FIPS mode not enabled");
-};
+#[no_mangle]
+pub extern "C" fn rdpclient_assert_fips_enabled() {
+ assert!(boring::fips::enabled(), "FIPS module for rdpclient not available");
+}
#[cfg(not(feature = "fips"))]
pub type TlsStream = ironrdp_tls::TlsStream;