@ship.zone/runner 2.1.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/.smartconfig.json +118 -3
  2. package/changelog.md +101 -0
  3. package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
  4. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.json +679 -0
  5. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.txt +15719 -0
  6. package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +5 -5
  7. package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
  8. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.json +679 -0
  9. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.txt +15719 -0
  10. package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +5 -5
  11. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  12. package/dist_ts/00_commitinfo_data.js +9 -0
  13. package/dist_ts/api-client.d.ts +47 -0
  14. package/dist_ts/api-client.js +600 -0
  15. package/dist_ts/artifact-manager.d.ts +11 -0
  16. package/dist_ts/artifact-manager.js +140 -0
  17. package/dist_ts/attempt-state.d.ts +18 -0
  18. package/dist_ts/attempt-state.js +151 -0
  19. package/dist_ts/cache-manager.d.ts +13 -0
  20. package/dist_ts/cache-manager.js +300 -0
  21. package/dist_ts/cli-entry.d.ts +2 -0
  22. package/dist_ts/cli-entry.js +18 -0
  23. package/dist_ts/cli.d.ts +14 -0
  24. package/dist_ts/cli.js +243 -0
  25. package/dist_ts/config.d.ts +8 -0
  26. package/dist_ts/config.js +495 -0
  27. package/dist_ts/egress-proxy.d.ts +99 -0
  28. package/dist_ts/egress-proxy.js +607 -0
  29. package/dist_ts/errors.d.ts +41 -0
  30. package/dist_ts/errors.js +90 -0
  31. package/dist_ts/filesystem.d.ts +73 -0
  32. package/dist_ts/filesystem.js +207 -0
  33. package/dist_ts/index.d.ts +20 -0
  34. package/dist_ts/index.js +21 -0
  35. package/dist_ts/interfaces.d.ts +685 -0
  36. package/dist_ts/interfaces.js +3 -0
  37. package/dist_ts/log-sender.d.ts +26 -0
  38. package/dist_ts/log-sender.js +124 -0
  39. package/dist_ts/microvm-executor.d.ts +90 -0
  40. package/dist_ts/microvm-executor.js +1045 -0
  41. package/dist_ts/node-version.d.ts +11 -0
  42. package/dist_ts/node-version.js +43 -0
  43. package/dist_ts/npm-grants.d.ts +9 -0
  44. package/dist_ts/npm-grants.js +44 -0
  45. package/dist_ts/oci-registry.d.ts +73 -0
  46. package/dist_ts/oci-registry.js +508 -0
  47. package/dist_ts/plugins.d.ts +23 -0
  48. package/dist_ts/plugins.js +27 -0
  49. package/dist_ts/protocol-validator.d.ts +39 -0
  50. package/dist_ts/protocol-validator.js +488 -0
  51. package/dist_ts/redactor.d.ts +78 -0
  52. package/dist_ts/redactor.js +235 -0
  53. package/dist_ts/registration-state.d.ts +16 -0
  54. package/dist_ts/registration-state.js +171 -0
  55. package/dist_ts/runner.d.ts +65 -0
  56. package/dist_ts/runner.js +912 -0
  57. package/dist_ts/source-workspace.d.ts +10 -0
  58. package/dist_ts/source-workspace.js +125 -0
  59. package/dist_ts/spec-version.d.ts +11 -0
  60. package/dist_ts/spec-version.js +41 -0
  61. package/dist_ts/staging-scavenger.d.ts +7 -0
  62. package/dist_ts/staging-scavenger.js +63 -0
  63. package/dist_ts/state-owner.d.ts +74 -0
  64. package/dist_ts/state-owner.js +291 -0
  65. package/dist_ts/transfer-archive.d.ts +78 -0
  66. package/dist_ts/transfer-archive.js +1619 -0
  67. package/dist_ts/validation.d.ts +11 -0
  68. package/dist_ts/validation.js +79 -0
  69. package/dist_ts/vsock-protocol.d.ts +130 -0
  70. package/dist_ts/vsock-protocol.js +336 -0
  71. package/dist_ts/wire-schema.d.ts +10 -0
  72. package/dist_ts/wire-schema.js +114 -0
  73. package/native-notices/crates/bitflags-2.13.1/license-apache +201 -0
  74. package/native-notices/crates/bitflags-2.13.1/license-mit +25 -0
  75. package/native-notices/crates/cc-1.8.0/license-apache +201 -0
  76. package/native-notices/crates/cc-1.8.0/license-mit +25 -0
  77. package/native-notices/crates/cfg-if-1.0.4/license-apache +201 -0
  78. package/native-notices/crates/cfg-if-1.0.4/license-mit +25 -0
  79. package/native-notices/crates/cfg_aliases-0.2.2/license +9 -0
  80. package/native-notices/crates/cfg_aliases-0.2.2/notices.md +26 -0
  81. package/native-notices/crates/find-msvc-tools-0.1.14/license-apache +201 -0
  82. package/native-notices/crates/find-msvc-tools-0.1.14/license-mit +25 -0
  83. package/native-notices/crates/itoa-1.0.18/license-apache +176 -0
  84. package/native-notices/crates/itoa-1.0.18/license-mit +23 -0
  85. package/native-notices/crates/libc-0.2.189/license-apache +176 -0
  86. package/native-notices/crates/libc-0.2.189/license-mit +25 -0
  87. package/native-notices/crates/memchr-2.8.3/copying +3 -0
  88. package/native-notices/crates/memchr-2.8.3/license-mit +21 -0
  89. package/native-notices/crates/memchr-2.8.3/unlicense +24 -0
  90. package/native-notices/crates/nix-0.30.1/license +21 -0
  91. package/native-notices/crates/proc-macro2-1.0.107/license-apache +176 -0
  92. package/native-notices/crates/proc-macro2-1.0.107/license-mit +23 -0
  93. package/native-notices/crates/quote-1.0.47/license-apache +176 -0
  94. package/native-notices/crates/quote-1.0.47/license-mit +23 -0
  95. package/native-notices/crates/serde-1.0.229/license-apache +176 -0
  96. package/native-notices/crates/serde-1.0.229/license-mit +23 -0
  97. package/native-notices/crates/serde_core-1.0.229/license-apache +176 -0
  98. package/native-notices/crates/serde_core-1.0.229/license-mit +23 -0
  99. package/native-notices/crates/serde_derive-1.0.229/license-apache +176 -0
  100. package/native-notices/crates/serde_derive-1.0.229/license-mit +23 -0
  101. package/native-notices/crates/serde_json-1.0.151/license-apache +176 -0
  102. package/native-notices/crates/serde_json-1.0.151/license-mit +23 -0
  103. package/native-notices/crates/shlex-2.0.1/license-apache +13 -0
  104. package/native-notices/crates/shlex-2.0.1/license-mit +21 -0
  105. package/native-notices/crates/syn-3.0.3/license-apache +176 -0
  106. package/native-notices/crates/syn-3.0.3/license-mit +23 -0
  107. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-apache +201 -0
  108. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-mit +25 -0
  109. package/native-notices/crates/tikv-jemallocator-0.7.0/license-apache +201 -0
  110. package/native-notices/crates/tikv-jemallocator-0.7.0/license-mit +25 -0
  111. package/native-notices/crates/unicode-ident-1.0.24/license-apache +176 -0
  112. package/native-notices/crates/unicode-ident-1.0.24/license-mit +23 -0
  113. package/native-notices/crates/unicode-ident-1.0.24/license-unicode +39 -0
  114. package/native-notices/crates/zmij-1.0.23/license-mit +23 -0
  115. package/native-notices/manifest.json +763 -0
  116. package/native-notices/native/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/jemalloc-5.3.1/jemalloc-copying +27 -0
  117. package/native-notices/readme.md +46 -0
  118. package/native-notices/runtime/gcc/gpl-3.0.txt +674 -0
  119. package/native-notices/runtime/gcc/runtime-library-exception-3.1.txt +73 -0
  120. package/native-notices/runtime/libunwind-22.1.2/license.txt +311 -0
  121. package/native-notices/runtime/musl-1.2.5/copyright +193 -0
  122. package/native-notices/rust/compiler-builtins-license.txt +275 -0
  123. package/native-notices/rust/copyright-library.html +8266 -0
  124. package/native-notices/rust/crates/addr2line-0.25.1/license-apache +201 -0
  125. package/native-notices/rust/crates/addr2line-0.25.1/license-mit +25 -0
  126. package/native-notices/rust/crates/adler2-2.0.1/license-0bsd +12 -0
  127. package/native-notices/rust/crates/adler2-2.0.1/license-apache +201 -0
  128. package/native-notices/rust/crates/adler2-2.0.1/license-mit +23 -0
  129. package/native-notices/rust/crates/memchr-2.7.6/copying +3 -0
  130. package/native-notices/rust/crates/memchr-2.7.6/license-mit +21 -0
  131. package/native-notices/rust/crates/memchr-2.7.6/unlicense +24 -0
  132. package/native-notices/rust/crates/miniz_oxide-0.8.9/license +25 -0
  133. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-apache.md +177 -0
  134. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-mit.md +24 -0
  135. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-zlib.md +14 -0
  136. package/native-notices/rust/crates/object-0.37.3/license-apache +201 -0
  137. package/native-notices/rust/crates/object-0.37.3/license-mit +25 -0
  138. package/native-notices/rust/licenses/apache-2.0.txt +73 -0
  139. package/native-notices/rust/licenses/bsd-2-clause.txt +9 -0
  140. package/native-notices/rust/licenses/cc-by-sa-4.0.txt +427 -0
  141. package/native-notices/rust/licenses/gcc-exception-3.1.txt +30 -0
  142. package/native-notices/rust/licenses/gpl-2.0-only.txt +133 -0
  143. package/native-notices/rust/licenses/gpl-3.0-or-later.txt +202 -0
  144. package/native-notices/rust/licenses/isc.txt +7 -0
  145. package/native-notices/rust/licenses/llvm-exception.txt +15 -0
  146. package/native-notices/rust/licenses/mit.txt +9 -0
  147. package/native-notices/rust/licenses/ncsa.txt +29 -0
  148. package/native-notices/rust/licenses/ofl-1.1.txt +43 -0
  149. package/native-notices/rust/licenses/unicode-3.0.txt +39 -0
  150. package/package.json +31 -26
  151. package/readme.md +157 -95
  152. package/rust/.cargo/config.toml +1 -1
  153. package/rust/Cargo.lock +1 -0
  154. package/rust/Cargo.toml +3 -2
  155. package/rust/src/cpio.rs +147 -0
  156. package/rust/src/extfs.rs +747 -0
  157. package/rust/src/guest.rs +2411 -0
  158. package/rust/src/lib.rs +197 -1
  159. package/rust/src/main.rs +7 -2
  160. package/rust/src/oci_tar.rs +842 -0
  161. package/rust-toolchain.toml +4 -0
  162. package/ts/00_commitinfo_data.ts +2 -2
  163. package/ts/api-client.ts +29 -8
  164. package/ts/artifact-manager.ts +9 -7
  165. package/ts/attempt-state.ts +75 -84
  166. package/ts/cache-manager.ts +22 -28
  167. package/ts/cli-entry.ts +17 -0
  168. package/ts/cli.ts +86 -53
  169. package/ts/config.ts +146 -62
  170. package/ts/egress-proxy.ts +649 -0
  171. package/ts/errors.ts +19 -0
  172. package/ts/filesystem.ts +316 -0
  173. package/ts/index.ts +20 -15
  174. package/ts/interfaces.ts +105 -23
  175. package/ts/log-sender.ts +4 -4
  176. package/ts/microvm-executor.ts +1265 -0
  177. package/ts/node-version.ts +49 -0
  178. package/ts/npm-grants.ts +49 -0
  179. package/ts/oci-registry.ts +649 -0
  180. package/ts/plugins.ts +25 -3
  181. package/ts/protocol-validator.ts +34 -30
  182. package/ts/redactor.ts +2 -2
  183. package/ts/registration-state.ts +82 -90
  184. package/ts/runner.ts +81 -34
  185. package/ts/source-workspace.ts +11 -8
  186. package/ts/spec-version.ts +2 -2
  187. package/ts/staging-scavenger.ts +37 -26
  188. package/ts/state-owner.ts +353 -0
  189. package/ts/transfer-archive.ts +214 -243
  190. package/ts/validation.ts +1 -1
  191. package/ts/vsock-protocol.ts +437 -0
  192. package/ts/wire-schema.ts +3 -3
  193. package/deno.json +0 -56
  194. package/deno.lock +0 -1495
  195. package/dist_npm/mod.d.ts +0 -967
  196. package/dist_npm/mod.js +0 -10058
  197. package/mod.ts +0 -8
  198. package/musl-copyright.md +0 -81
  199. package/third-party-licenses.md +0 -187
  200. package/ts/oci-executor.ts +0 -3137
package/rust/src/lib.rs CHANGED
@@ -1,6 +1,11 @@
1
1
  #[cfg(not(unix))]
2
2
  compile_error!("runnerworkspace requires a Unix platform");
3
3
 
4
+ pub mod cpio;
5
+ pub mod extfs;
6
+ pub mod guest;
7
+ pub mod oci_tar;
8
+
4
9
  use serde::Serialize;
5
10
  use std::ffi::CString;
6
11
  use std::ffi::OsString;
@@ -17,6 +22,8 @@ const COPY_BUFFER_SIZE: usize = 64 * 1024;
17
22
  const MAXIMUM_TRAVERSAL_DEPTH: usize = 256;
18
23
  const HOLD_PARK_INTERVAL: Duration = Duration::from_millis(100);
19
24
  const RESERVE_FILE_NAME: &str = ".runnerworkspace-reserve";
25
+ const STATE_OWNER_LOCK_NAME: &str = ".runner-owner.lock";
26
+ const STATE_OWNER_LOCK_MODE: u32 = 0o600;
20
27
  const DESTINATION_CLEANUP_FAILURE: &str = "unable to clean destination after failure";
21
28
  const RESERVE_CLEANUP_FAILURE: &str = "unable to clean volume after reserve failure";
22
29
 
@@ -24,14 +31,33 @@ static HOLD_TERMINATION_REQUESTED: AtomicBool = AtomicBool::new(false);
24
31
 
25
32
  type Result<T> = std::result::Result<T, Error>;
26
33
 
34
+ /// Exit code of `own-state` when another process already holds the runner state lock.
35
+ pub const STATE_OWNED_ELSEWHERE_EXIT_CODE: i32 = 3;
36
+
27
37
  #[derive(Debug, Clone, Copy, Eq, PartialEq)]
28
38
  pub struct Error {
29
39
  message: &'static str,
40
+ exit_code: i32,
30
41
  }
31
42
 
32
43
  impl Error {
33
44
  const fn new(message: &'static str) -> Self {
34
- Self { message }
45
+ Self {
46
+ message,
47
+ exit_code: 1,
48
+ }
49
+ }
50
+
51
+ const fn state_owned_elsewhere() -> Self {
52
+ Self {
53
+ message: "runner state is owned by another process",
54
+ exit_code: STATE_OWNED_ELSEWHERE_EXIT_CODE,
55
+ }
56
+ }
57
+
58
+ /// The process exit code that reports this error.
59
+ pub const fn exit_code(&self) -> i32 {
60
+ self.exit_code
35
61
  }
36
62
  }
37
63
 
@@ -630,10 +656,134 @@ where
630
656
  ownership,
631
657
  )?)
632
658
  }
659
+ "own-state" => {
660
+ let state_directory = PathBuf::from(
661
+ iterator
662
+ .next()
663
+ .ok_or_else(|| Error::new("own-state requires a state directory"))?,
664
+ );
665
+ if iterator.next().is_some() {
666
+ return Err(Error::new("own-state accepts only a state directory"));
667
+ }
668
+ own_state(&state_directory)
669
+ }
670
+ "build-initrd" => {
671
+ let mut options = Options::parse(iterator)?;
672
+ let binary = PathBuf::from(options.take_one("--binary")?);
673
+ let output = PathBuf::from(options.take_one("--output")?);
674
+ options.finish()?;
675
+ let bytes = cpio::build_initrd(&binary, &output)?;
676
+ emit_json(&serde_json::json!({ "bytes": bytes }))
677
+ }
678
+ "build-rootfs" => {
679
+ let mut options = Options::parse(iterator)?;
680
+ let output = PathBuf::from(options.take_one("--output")?);
681
+ let maximum_bytes = parse_u64(options.take_one("--maximum-bytes")?)?;
682
+ let layers = options
683
+ .take_many("--layer")
684
+ .into_iter()
685
+ .map(PathBuf::from)
686
+ .collect::<Vec<_>>();
687
+ options.finish()?;
688
+ let layer_refs = layers.iter().map(PathBuf::as_path).collect::<Vec<_>>();
689
+ let root = oci_tar::apply_oci_layers(&layer_refs, maximum_bytes)?;
690
+ let bytes = extfs::write_ext2_image(&root, &output)?;
691
+ emit_json(&serde_json::json!({ "bytes": bytes }))
692
+ }
693
+ "guest-init" => {
694
+ let mut options = Options::parse(iterator)?;
695
+ let unix_socket = options.take_one("--unix-socket").ok().map(PathBuf::from);
696
+ let workspace = options.take_one("--workspace").ok().map(PathBuf::from);
697
+ options.finish()?;
698
+ match (unix_socket, workspace) {
699
+ (Some(sock), Some(ws)) => guest::serve_unix_socket(&sock, &ws),
700
+ (None, None) => guest::run_pid1(),
701
+ _ => Err(Error::new(
702
+ "guest-init requires both --unix-socket and --workspace or neither",
703
+ )),
704
+ }
705
+ }
633
706
  _ => Err(Error::new("unknown command")),
634
707
  }
635
708
  }
636
709
 
710
+ /// Holds the exclusive runner state lock for the lifetime of the parent runner process.
711
+ ///
712
+ /// The lock is a kernel `flock` on `<state>/.runner-owner.lock`, so it ends with this process.
713
+ /// Once held, `locked` is printed and the helper waits for end of input on stdin, which the runner
714
+ /// closes on release or exit. The parent-death signal is a backstop for a parent that dies
715
+ /// without closing stdin. Interactive and service-manager termination signals are ignored, so
716
+ /// the lock outlives a graceful runner shutdown until the runner releases it.
717
+ fn own_state(state_directory: &Path) -> Result<()> {
718
+ use nix::sys::signal::{self, SigHandler, Signal};
719
+
720
+ let parent = std::os::unix::process::parent_id();
721
+ nix::sys::prctl::set_pdeathsig(Signal::SIGKILL)
722
+ .map_err(|_| Error::new("unable to set the parent-death signal"))?;
723
+ if std::os::unix::process::parent_id() != parent {
724
+ return Err(Error::new("runner exited before the state lock was taken"));
725
+ }
726
+ for ignored in [Signal::SIGINT, Signal::SIGTERM, Signal::SIGHUP] {
727
+ // Ignoring a signal installs no handler code, so no async-signal-safety rule applies.
728
+ unsafe { signal::signal(ignored, SigHandler::SigIgn) }
729
+ .map_err(|_| Error::new("unable to ignore termination signals"))?;
730
+ }
731
+ let lock = lock_state_directory(state_directory)?;
732
+ {
733
+ let stdout = io::stdout();
734
+ let mut output = stdout.lock();
735
+ output
736
+ .write_all(b"locked\n")
737
+ .and_then(|()| output.flush())
738
+ .map_err(|_| Error::new("unable to report the state lock"))?;
739
+ }
740
+ wait_for_end_of_input(io::stdin().lock())?;
741
+ drop(lock);
742
+ Ok(())
743
+ }
744
+
745
+ fn lock_state_directory(state_directory: &Path) -> Result<nix::fcntl::Flock<fs::File>> {
746
+ use nix::fcntl::{Flock, FlockArg};
747
+
748
+ require_absolute(state_directory)?;
749
+ let file = OpenOptions::new()
750
+ .read(true)
751
+ .write(true)
752
+ .create(true)
753
+ .mode(STATE_OWNER_LOCK_MODE)
754
+ .custom_flags(nix::libc::O_CLOEXEC | nix::libc::O_NOFOLLOW)
755
+ .open(state_directory.join(STATE_OWNER_LOCK_NAME))
756
+ .map_err(|_| Error::new("unable to open the runner state lock"))?;
757
+ let metadata = file
758
+ .metadata()
759
+ .map_err(|_| Error::new("unable to inspect the runner state lock"))?;
760
+ if !metadata.file_type().is_file()
761
+ || metadata.nlink() != 1
762
+ || metadata.uid() != nix::unistd::geteuid().as_raw()
763
+ {
764
+ return Err(Error::new(
765
+ "runner state lock must be a single-link regular file owned by the runner",
766
+ ));
767
+ }
768
+ match Flock::lock(file, FlockArg::LockExclusiveNonblock) {
769
+ Ok(lock) => Ok(lock),
770
+ Err((_, nix::errno::Errno::EWOULDBLOCK)) => Err(Error::state_owned_elsewhere()),
771
+ Err(_) => Err(Error::new("unable to lock the runner state")),
772
+ }
773
+ }
774
+
775
+ fn wait_for_end_of_input<R: Read>(mut input: R) -> Result<()> {
776
+ let mut buffer = [0_u8; 64];
777
+ loop {
778
+ match input.read(&mut buffer) {
779
+ Ok(0) => return Ok(()),
780
+ Ok(_) => {}
781
+ Err(error) if error.kind() == io::ErrorKind::Interrupted => {}
782
+ Err(_) => return Err(Error::new("unable to read the state owner input")),
783
+ }
784
+ }
785
+ }
786
+
637
787
  fn emit_json<T: Serialize>(value: &T) -> Result<()> {
638
788
  let stdout = io::stdout();
639
789
  let mut output = stdout.lock();
@@ -1730,6 +1880,52 @@ mod tests {
1730
1880
  assert!(termination_requested.load(Ordering::Relaxed));
1731
1881
  }
1732
1882
 
1883
+ #[test]
1884
+ fn state_lock_is_exclusive_and_released_with_its_holder() {
1885
+ let temporary = TestDirectory::new();
1886
+ let first = lock_state_directory(&temporary.path).expect("first lock");
1887
+ assert_eq!(
1888
+ lock_state_directory(&temporary.path).unwrap_err(),
1889
+ Error::state_owned_elsewhere()
1890
+ );
1891
+ assert_eq!(
1892
+ Error::state_owned_elsewhere().exit_code(),
1893
+ STATE_OWNED_ELSEWHERE_EXIT_CODE
1894
+ );
1895
+ drop(first);
1896
+ let second = lock_state_directory(&temporary.path).expect("lock after release");
1897
+ let metadata = fs::symlink_metadata(temporary.child(STATE_OWNER_LOCK_NAME)).unwrap();
1898
+ assert_eq!(metadata.permissions().mode() & 0o777, STATE_OWNER_LOCK_MODE);
1899
+ drop(second);
1900
+ }
1901
+
1902
+ #[test]
1903
+ fn state_lock_rejects_links_and_relative_directories() {
1904
+ let temporary = TestDirectory::new();
1905
+ let target = temporary.child("target");
1906
+ write_file(&target, b"");
1907
+ std::os::unix::fs::symlink(&target, temporary.child(STATE_OWNER_LOCK_NAME)).unwrap();
1908
+ assert_eq!(
1909
+ lock_state_directory(&temporary.path).unwrap_err(),
1910
+ Error::new("unable to open the runner state lock")
1911
+ );
1912
+ fs::remove_file(temporary.child(STATE_OWNER_LOCK_NAME)).unwrap();
1913
+ fs::hard_link(&target, temporary.child(STATE_OWNER_LOCK_NAME)).unwrap();
1914
+ assert_eq!(
1915
+ lock_state_directory(&temporary.path).unwrap_err(),
1916
+ Error::new("runner state lock must be a single-link regular file owned by the runner")
1917
+ );
1918
+ assert_eq!(
1919
+ lock_state_directory(Path::new("relative")).unwrap_err(),
1920
+ Error::new("root paths must be absolute")
1921
+ );
1922
+ }
1923
+
1924
+ #[test]
1925
+ fn state_owner_waits_for_end_of_input() {
1926
+ wait_for_end_of_input(&b"ignored input"[..]).expect("end of input");
1927
+ }
1928
+
1733
1929
  #[test]
1734
1930
  fn reports_statvfs_values() {
1735
1931
  let temporary = TestDirectory::new();
package/rust/src/main.rs CHANGED
@@ -3,8 +3,13 @@
3
3
  static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
4
4
 
5
5
  fn main() {
6
- if let Err(error) = runnerworkspace::run(std::env::args_os().skip(1)) {
6
+ let result = if runnerworkspace::guest::invoked_as_pid1() {
7
+ runnerworkspace::guest::run_pid1()
8
+ } else {
9
+ runnerworkspace::run(std::env::args_os().skip(1))
10
+ };
11
+ if let Err(error) = result {
7
12
  eprintln!("runnerworkspace: {error}");
8
- std::process::exit(1);
13
+ std::process::exit(error.exit_code());
9
14
  }
10
15
  }