diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 3fcc16a7..18c3b783 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -3,4 +3,7 @@ Cargo.lock doc/GPA Arch Diagram.vsdx doc/GuestProxyAgent.png e2etest/GuestProxyAgentTest/Resources/GuestProxyAgentLoadedModulesBaseline.txt -proxy_agent_shared/src/secrets_redactor.rs \ No newline at end of file +proxy_agent_shared/src/secrets_redactor.rs +rpmbuild/SOURCES/0001-Update-Cargo-files-for-Linux-only.patch +rpmbuild/SOURCES/0002-Fix-doc-test.patch +rpmbuild/SOURCES/0003-Add-feature-for-linux-service-test.patch \ No newline at end of file diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 7809ed51..c660e168 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -8,11 +8,15 @@ almalinux ATL ATLMFC autobuild +autochangelog +autorelease +autosetup autocrlf aya AZUREPUBLICCLOUD azuretools backcompat +bcond bierner binpath binskim @@ -24,6 +28,7 @@ btrfs bufptr Bufs BUILDIN +buildrequires buildroot buildshell byos @@ -131,6 +136,7 @@ idstepsrun IEnumerable ieq iex +ifarch ifaddrs ifindex IList diff --git a/.gitignore b/.gitignore index 41e88617..78fa7f75 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ /rpm-build/RPMS/ /rpm-build/SRPMS/ /debbuild/ +/rpmbuild/BUILD/ +/rpmbuild/RPMS/ +/rpmbuild/SRPMS/ .idea/ diff --git a/rpmbuild/SOURCES/0001-Update-Cargo-files-for-Linux-only.patch b/rpmbuild/SOURCES/0001-Update-Cargo-files-for-Linux-only.patch new file mode 100644 index 00000000..e4759394 --- /dev/null +++ b/rpmbuild/SOURCES/0001-Update-Cargo-files-for-Linux-only.patch @@ -0,0 +1,652 @@ +From effe906305640d424e541eb1af822c2002fc9e1f Mon Sep 17 00:00:00 2001 +From: ZhidongPeng +Date: Wed, 24 Sep 2025 16:57:57 +0000 +Subject: [PATCH] Update Cargo files for Linux only + +--- + Cargo.lock | 356 +--------------------------------- + Cargo.toml | 2 - + proxy_agent/Cargo.toml | 48 ----- + proxy_agent_shared/Cargo.toml | 21 -- + 4 files changed, 1 insertion(+), 426 deletions(-) + +diff --git a/Cargo.lock b/Cargo.lock +index 43e2eec..5fa87fd 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -2,25 +2,6 @@ + # It is not intended for manual editing. + version = 4 + +-[[package]] +-name = "ProxyAgentExt" +-version = "1.0.36" +-dependencies = [ +- "clap", +- "ctor", +- "nix", +- "once_cell", +- "proxy_agent_shared", +- "serde", +- "serde_json", +- "static_vcruntime", +- "sysinfo", +- "thiserror", +- "tokio", +- "windows-service", +- "winres", +-] +- + [[package]] + name = "addr2line" + version = "0.24.1" +@@ -63,21 +44,6 @@ version = "0.2.18" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +-[[package]] +-name = "android-tzdata" +-version = "0.1.1" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +- +-[[package]] +-name = "android_system_properties" +-version = "0.1.5" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +-dependencies = [ +- "libc", +-] +- + [[package]] + name = "anstream" + version = "0.6.15" +@@ -186,7 +152,6 @@ dependencies = [ + "hyper-util", + "itertools", + "libc", +- "libloading", + "nix", + "once_cell", + "proxy_agent_shared", +@@ -195,7 +160,6 @@ dependencies = [ + "serde-xml-rs", + "serde_derive", + "serde_json", +- "static_vcruntime", + "sysinfo", + "thiserror", + "tokio", +@@ -204,11 +168,6 @@ dependencies = [ + "tower-http", + "uuid", + "uzers", +- "winapi", +- "windows-acl", +- "windows-service", +- "windows-sys", +- "winres", + ] + + [[package]] +@@ -232,12 +191,6 @@ version = "2.6.0" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +-[[package]] +-name = "bumpalo" +-version = "3.18.1" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" +- + [[package]] + name = "byteorder" + version = "1.5.0" +@@ -250,15 +203,6 @@ version = "1.7.1" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + +-[[package]] +-name = "cc" +-version = "1.2.27" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" +-dependencies = [ +- "shlex", +-] +- + [[package]] + name = "cfg-if" + version = "1.0.0" +@@ -271,20 +215,6 @@ version = "0.2.1" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +-[[package]] +-name = "chrono" +-version = "0.4.41" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +-dependencies = [ +- "android-tzdata", +- "iana-time-zone", +- "js-sys", +- "num-traits", +- "wasm-bindgen", +- "windows-link", +-] +- + [[package]] + name = "clap" + version = "4.5.18" +@@ -425,16 +355,6 @@ version = "1.0.1" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +-[[package]] +-name = "field-offset" +-version = "0.3.6" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +-dependencies = [ +- "memoffset", +- "rustc_version", +-] +- + [[package]] + name = "fnv" + version = "1.0.7" +@@ -638,30 +558,6 @@ dependencies = [ + "tokio", + ] + +-[[package]] +-name = "iana-time-zone" +-version = "0.1.63" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +-dependencies = [ +- "android_system_properties", +- "core-foundation-sys", +- "iana-time-zone-haiku", +- "js-sys", +- "log", +- "wasm-bindgen", +- "windows-core 0.61.2", +-] +- +-[[package]] +-name = "iana-time-zone-haiku" +-version = "0.1.2" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +-dependencies = [ +- "cc", +-] +- + [[package]] + name = "indexmap" + version = "2.7.1" +@@ -693,32 +589,12 @@ version = "1.0.11" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +-[[package]] +-name = "js-sys" +-version = "0.3.77" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +-dependencies = [ +- "once_cell", +- "wasm-bindgen", +-] +- + [[package]] + name = "libc" + version = "0.2.171" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +-[[package]] +-name = "libloading" +-version = "0.8.5" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +-dependencies = [ +- "cfg-if", +- "windows-targets", +-] +- + [[package]] + name = "log" + version = "0.4.26" +@@ -863,24 +739,11 @@ dependencies = [ + "unicode-ident", + ] + +-[[package]] +-name = "proxy_agent_setup" +-version = "1.0.36" +-dependencies = [ +- "clap", +- "proxy_agent_shared", +- "static_vcruntime", +- "thiserror", +- "tokio", +- "winres", +-] +- + [[package]] + name = "proxy_agent_shared" + version = "1.0.36" + dependencies = [ + "backtrace", +- "chrono", + "concurrent-queue", + "ctor", + "log", +@@ -888,16 +751,12 @@ dependencies = [ + "os_info", + "regex", + "serde", +- "serde-xml-rs", + "serde_derive", + "serde_json", + "thiserror", + "thread-id", + "time", + "tokio", +- "windows-service", +- "windows-sys", +- "winreg", + ] + + [[package]] +@@ -994,33 +853,12 @@ version = "0.1.24" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +-[[package]] +-name = "rustc_version" +-version = "0.4.1" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +-dependencies = [ +- "semver", +-] +- +-[[package]] +-name = "rustversion" +-version = "1.0.21" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +- + [[package]] + name = "ryu" + version = "1.0.18" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +-[[package]] +-name = "semver" +-version = "1.0.23" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +- + [[package]] + name = "serde" + version = "1.0.210" +@@ -1065,12 +903,6 @@ dependencies = [ + "serde", + ] + +-[[package]] +-name = "shlex" +-version = "1.3.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +- + [[package]] + name = "slab" + version = "0.4.9" +@@ -1096,12 +928,6 @@ dependencies = [ + "windows-sys", + ] + +-[[package]] +-name = "static_vcruntime" +-version = "2.0.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "954e3e877803def9dc46075bf4060147c55cd70db97873077232eae0269dc89b" +- + [[package]] + name = "strsim" + version = "0.11.1" +@@ -1240,15 +1066,6 @@ dependencies = [ + "tokio", + ] + +-[[package]] +-name = "toml" +-version = "0.5.11" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +-dependencies = [ +- "serde", +-] +- + [[package]] + name = "tower" + version = "0.5.2" +@@ -1387,76 +1204,6 @@ version = "0.11.0+wasi-snapshot-preview1" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +-[[package]] +-name = "wasm-bindgen" +-version = "0.2.100" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +-dependencies = [ +- "cfg-if", +- "once_cell", +- "rustversion", +- "wasm-bindgen-macro", +-] +- +-[[package]] +-name = "wasm-bindgen-backend" +-version = "0.2.100" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +-dependencies = [ +- "bumpalo", +- "log", +- "proc-macro2", +- "quote", +- "syn", +- "wasm-bindgen-shared", +-] +- +-[[package]] +-name = "wasm-bindgen-macro" +-version = "0.2.100" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +-dependencies = [ +- "quote", +- "wasm-bindgen-macro-support", +-] +- +-[[package]] +-name = "wasm-bindgen-macro-support" +-version = "0.2.100" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +-dependencies = [ +- "proc-macro2", +- "quote", +- "syn", +- "wasm-bindgen-backend", +- "wasm-bindgen-shared", +-] +- +-[[package]] +-name = "wasm-bindgen-shared" +-version = "0.2.100" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +-dependencies = [ +- "unicode-ident", +-] +- +-[[package]] +-name = "widestring" +-version = "0.4.3" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" +- +-[[package]] +-name = "widestring" +-version = "1.1.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" +- + [[package]] + name = "winapi" + version = "0.3.9" +@@ -1485,22 +1232,10 @@ version = "0.52.0" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" + dependencies = [ +- "windows-core 0.52.0", ++ "windows-core", + "windows-targets", + ] + +-[[package]] +-name = "windows-acl" +-version = "0.3.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "177b1723986bcb4c606058e77f6e8614b51c7f9ad2face6f6fd63dd5c8b3cec3" +-dependencies = [ +- "field-offset", +- "libc", +- "widestring 0.4.3", +- "winapi", +-] +- + [[package]] + name = "windows-core" + version = "0.52.0" +@@ -1510,76 +1245,6 @@ dependencies = [ + "windows-targets", + ] + +-[[package]] +-name = "windows-core" +-version = "0.61.2" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +-dependencies = [ +- "windows-implement", +- "windows-interface", +- "windows-link", +- "windows-result", +- "windows-strings", +-] +- +-[[package]] +-name = "windows-implement" +-version = "0.60.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +-dependencies = [ +- "proc-macro2", +- "quote", +- "syn", +-] +- +-[[package]] +-name = "windows-interface" +-version = "0.59.1" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +-dependencies = [ +- "proc-macro2", +- "quote", +- "syn", +-] +- +-[[package]] +-name = "windows-link" +-version = "0.1.3" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +- +-[[package]] +-name = "windows-result" +-version = "0.3.4" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +-dependencies = [ +- "windows-link", +-] +- +-[[package]] +-name = "windows-service" +-version = "0.7.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "d24d6bcc7f734a4091ecf8d7a64c5f7d7066f45585c1861eba06449909609c8a" +-dependencies = [ +- "bitflags", +- "widestring 1.1.0", +- "windows-sys", +-] +- +-[[package]] +-name = "windows-strings" +-version = "0.4.2" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +-dependencies = [ +- "windows-link", +-] +- + [[package]] + name = "windows-sys" + version = "0.52.0" +@@ -1653,25 +1318,6 @@ version = "0.52.6" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +-[[package]] +-name = "winreg" +-version = "0.11.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189" +-dependencies = [ +- "cfg-if", +- "winapi", +-] +- +-[[package]] +-name = "winres" +-version = "0.1.12" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +-dependencies = [ +- "toml", +-] +- + [[package]] + name = "xml-rs" + version = "0.8.22" +diff --git a/Cargo.toml b/Cargo.toml +index 5e7c5b7..be11033 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -5,8 +5,6 @@ resolver = "2" + members = [ + "proxy_agent_shared", + "proxy_agent", +- "proxy_agent_extension", +- "proxy_agent_setup", + ] + + exclude = [ +diff --git a/proxy_agent/Cargo.toml b/proxy_agent/Cargo.toml +index 45633eb..f270623 100644 +--- a/proxy_agent/Cargo.toml ++++ b/proxy_agent/Cargo.toml +@@ -51,53 +51,5 @@ features = [ + "user" + ] + +-[target.'cfg(windows)'.dependencies] +-windows-service = "0.7.0" # windows NT service +-windows-acl = "0.3.0" # ACL the latch key folder +-winapi = "0.3.9" # used by windows-acl PSID +-libloading = "0.8.0" # for dynamic load libraries +- +-[target.'cfg(windows)'.build-dependencies] +-winres = "0.1.12" # Rust Windows resource helper to add file version +-static_vcruntime = "2.0.0" # Statically link the VCRuntime when using the MSVC toolchain +- +-[target.'cfg(windows)'.dependencies.windows-sys] +-version = "0.52.0" +-features = [ +- "Wdk_Foundation", +- "Wdk_System_Threading", +- "Win32_Foundation", +- "Win32_Networking_WinSock", +- "Win32_System_IO", +- "Win32_Security", +- "Win32_System_WindowsProgramming", +- "Win32_Security_Authentication_Identity", +- "Win32_System_Diagnostics_Debug", +- "Win32_System_SystemInformation", +- "Win32_System_Threading", +- "Win32_System_ProcessStatus", +- "Win32_System_Kernel", +- "Win32_Security_Cryptography", +- "Win32_System_Memory" +-] +- + [features] + test-with-root = [] +- +-[package.metadata.deb] +-name = "azure-proxy-agent" +-revision = "0" +-maintainer = "AzureRT ProxyAgent V Team " +-copyright = "2024, AzureRT ProxyAgent V Team " +-license-file = ["../LICENSE", "4"] +-extended-description = """\ +-The Azure Guest Proxy Agent is a daemon that runs on the Azure guest \ +-operating system and provides a proxy for the Azure Fabric Controller \ +-to communicate with the guest operating system.""" +-maintainer-scripts = "DEBIAN" +-systemd-units = { enable = true } +-assets = [ +- ["azure-proxy-agent", "usr/sbin/azure-proxy-agent", "755"], # Binary +- ["proxy-agent.json", "etc/azure/proxy-agent.json", "644"], +- ["ebpf_cgroup.o", "usr/lib/azure-proxy-agent/ebpf_cgroup.o", "644"], +-] +\ No newline at end of file +diff --git a/proxy_agent_shared/Cargo.toml b/proxy_agent_shared/Cargo.toml +index 45832cc..9cf6af1 100644 +--- a/proxy_agent_shared/Cargo.toml ++++ b/proxy_agent_shared/Cargo.toml +@@ -20,26 +20,5 @@ log = { version = "0.4.26", features = ["std"] } + ctor = "0.3.6" # used for test setup and clean up + backtrace = "0.3" # used for get the caller module and function name + +-[target.'cfg(windows)'.dependencies] +-windows-service = "0.7.0" # windows NT service +-winreg = "0.11.0" # windows reg read/write +-serde-xml-rs = "0.8.1" # xml Deserializer with xml attribute +-chrono = "0.4.41" # parse date time string +- +-[target.'cfg(windows)'.dependencies.windows-sys] +-version = "0.52.0" +-features = [ +- "Win32_Foundation", +- "Win32_Networking_WinSock", +- "Win32_System_IO", +- "Win32_Security", +- "Win32_System_EventLog", +- "Win32_System_WindowsProgramming", +- "Win32_Security_Authentication_Identity", +- "Win32_System_Diagnostics_Debug", +- "Win32_System_SystemInformation", +- "Win32_Storage_FileSystem", +-] +- + [target.'cfg(not(windows))'.dependencies] + os_info = "3.7.0" # read Linux OS version and arch +\ No newline at end of file +-- +2.51.0 + diff --git a/rpmbuild/SOURCES/0002-Fix-doc-test.patch b/rpmbuild/SOURCES/0002-Fix-doc-test.patch new file mode 100644 index 00000000..6a566328 --- /dev/null +++ b/rpmbuild/SOURCES/0002-Fix-doc-test.patch @@ -0,0 +1,25 @@ +From dda014e52c427043be3dbf95dc196a23e0cd06d2 Mon Sep 17 00:00:00 2001 +From: ZhidongPeng +Date: Wed, 24 Sep 2025 20:34:16 +0000 +Subject: [PATCH] Fix doc test + +--- + proxy_agent_shared/src/misc_helpers.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/proxy_agent_shared/src/misc_helpers.rs b/proxy_agent_shared/src/misc_helpers.rs +index 676a8e1..238b04c 100644 +--- a/proxy_agent_shared/src/misc_helpers.rs ++++ b/proxy_agent_shared/src/misc_helpers.rs +@@ -184,7 +184,7 @@ pub fn get_files(dir: &Path) -> Result> { + /// ```rust + /// use std::path::PathBuf; + /// use proxy_agent_shared::misc_helpers; +-/// let dir = PathBuf::from("C:\\"); ++/// let dir = PathBuf::from("."); + /// let search_regex_pattern = r"^(.*\.log)$"; // search for files with .log extension + /// let files = misc_helpers::search_files(&dir, search_regex_pattern).unwrap(); + /// +-- +2.51.0 + diff --git a/rpmbuild/SOURCES/0003-Add-feature-for-linux-service-test.patch b/rpmbuild/SOURCES/0003-Add-feature-for-linux-service-test.patch new file mode 100644 index 00000000..1a4b52fb --- /dev/null +++ b/rpmbuild/SOURCES/0003-Add-feature-for-linux-service-test.patch @@ -0,0 +1,40 @@ +From 872c1bf5d8b503359a0aecdd3b66d1ffed0c6b38 Mon Sep 17 00:00:00 2001 +From: ZhidongPeng +Date: Thu, 25 Sep 2025 19:20:53 +0000 +Subject: [PATCH] Add feature test-with-root for linux service unit tests + +--- + proxy_agent_shared/Cargo.toml | 5 ++++- + proxy_agent_shared/src/service.rs | 1 + + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/proxy_agent_shared/Cargo.toml b/proxy_agent_shared/Cargo.toml +index 9cf6af1..c8b70c6 100644 +--- a/proxy_agent_shared/Cargo.toml ++++ b/proxy_agent_shared/Cargo.toml +@@ -21,4 +21,7 @@ ctor = "0.3.6" # used for test setup and clean up + backtrace = "0.3" # used for get the caller module and function name + + [target.'cfg(not(windows))'.dependencies] +-os_info = "3.7.0" # read Linux OS version and arch +\ No newline at end of file ++os_info = "3.7.0" # read Linux OS version and arch ++ ++[features] ++test-with-root = [] +\ No newline at end of file +diff --git a/proxy_agent_shared/src/service.rs b/proxy_agent_shared/src/service.rs +index 5ca4b89..3eade7c 100644 +--- a/proxy_agent_shared/src/service.rs ++++ b/proxy_agent_shared/src/service.rs +@@ -147,6 +147,7 @@ pub fn check_service_installed(_service_name: &str) -> (bool, String) { + #[cfg(windows)] + pub use windows_service::set_default_failure_actions; + ++#[cfg(feature = "test-with-root")] + #[cfg(test)] + mod tests { + #[test] +-- +2.51.0 + diff --git a/rpmbuild/SOURCES/azure-proxy-agent-1.0.36.tar.gz b/rpmbuild/SOURCES/azure-proxy-agent-1.0.36.tar.gz new file mode 100644 index 00000000..d4885b55 Binary files /dev/null and b/rpmbuild/SOURCES/azure-proxy-agent-1.0.36.tar.gz differ diff --git a/rpmbuild/SOURCES/vendor.tar.xz b/rpmbuild/SOURCES/vendor.tar.xz new file mode 100644 index 00000000..748dbe57 Binary files /dev/null and b/rpmbuild/SOURCES/vendor.tar.xz differ diff --git a/rpmbuild/SPECS/azure-proxy-agent.spec b/rpmbuild/SPECS/azure-proxy-agent.spec new file mode 100644 index 00000000..28f5c445 --- /dev/null +++ b/rpmbuild/SPECS/azure-proxy-agent.spec @@ -0,0 +1,90 @@ +# Generated by rust2rpm 27 and manual updated for service install and local build +# rust2rpm azure-proxy-agent --path ../proxy_agent/Cargo.toml + +%bcond check 1 + +Name: azure-proxy-agent +Version: 1.0.36 +Release: %autorelease +Summary: Microsoft Azure Guest Proxy Agent +SourceLicense: MIT +License: MIT +URL: https://github.com/Azure/GuestProxyAgent +Source0: %{name}-%{version}.tar.gz +# vendor.tar.xz for local build only +Source1: vendor.tar.xz +Patch0: 0001-Update-Cargo-files-for-Linux-only.patch +Patch1: 0002-Fix-doc-test.patch +Patch2: 0003-Add-feature-for-linux-service-test.patch +ExclusiveArch: x86_64 aarch64 + +BuildRequires: cargo-rpm-macros >= 24 +BuildRequires: clang +BuildRequires: libbpf-devel + +%global _description %{expand: +Azure Guest Proxy Agent.} + +%description %{_description} +%global _ebpf_path linux-ebpf + +%prep +%autosetup -p1 -a0 +# %cargo_prep +# vendor mode for local build and manual extract Source1 into vendor +mkdir vendor +tar -xf %{SOURCE1} -C vendor +%cargo_prep -v vendor + +### %cargo_generate_buildrequires inspects Cargo.lock and emits BuildRequires: crate(...) lines. +### Those are only for offline builds using system crates, not for vendor builds +# %generate_buildrequires +# %cargo_generate_buildrequires + +%build +# build ebpf +ebpf_arch=x86 +ebpf_arch_inc= +%ifarch aarch64 +ebpf_arch=arm64 +ebpf_arch_inc=aarch64-linux-gnu +%endif +clang -g -target bpf -Werror -O2 -D__TARGET_ARCH_$ebpf_arch -I/usr/include/$ebpf_arch_inc -c %{_ebpf_path}/ebpf_cgroup.c -o %{_ebpf_path}/ebpf_cgroup.o +# build rust +%cargo_vendor_manifest +%cargo_build + +%install +# customized install the files for azure-proxy-agent service +mkdir -p %{buildroot}/usr/sbin/ +mkdir -p %{buildroot}/etc/azure/ +mkdir -p %{buildroot}/usr/lib/systemd/system/ +mkdir -p %{buildroot}/usr/lib/azure-proxy-agent/ +cp -f proxy_agent/config/GuestProxyAgent.linux.json %{buildroot}/etc/azure/proxy-agent.json +cp -f proxy_agent_setup/src/linux/azure-proxy-agent.service %{buildroot}/usr/lib/systemd/system/ +cp -f %{_ebpf_path}/ebpf_cgroup.o %{buildroot}/usr/lib/azure-proxy-agent/ +cp -f target/release/azure-proxy-agent %{buildroot}/usr/sbin/ + +%if %{with check} +%check +cp -f -T proxy_agent/config/GuestProxyAgent.linux.json target/release/deps/proxy-agent.json +%cargo_test +%endif + +%post +%systemd_post azure-proxy-agent.service + systemctl unmask azure-proxy-agent.service + systemctl daemon-reload + systemctl start azure-proxy-agent.service + systemctl enable azure-proxy-agent.service + +%files +%license LICENSE +%defattr(-,root,root,-) +/usr/lib/systemd/system/azure-proxy-agent.service +/usr/sbin/azure-proxy-agent +/etc/azure/proxy-agent.json +/usr/lib/azure-proxy-agent/ebpf_cgroup.o + +%changelog +%autochangelog