Skip to content

Commit b47c5dc

Browse files
committed
Windows: Avoid permission issues when building envs. as non-privileged user
Previously, we built environments with the following command: ``` rcc task script -- rcc -v ------ essentially a no-op ``` For unprivileged users, this can fail with: ``` Error: Access is denied. [rcc] exit status will be: 7! ``` Before executing the command line handed over to `rcc task script`, RCC checks internally if the first value of the command line exists and tries to resolve it if it is a symlink: https://github.com/robocorp/rcc/blob/db661af9d28a61a2dbc3656260de6c29dbe01bcd/operations/running.go#L276 This symlink resolution step (`filepath.EvalSymlinks`) apparently fails on Windows systems if the user has insufficient permissions to access the parent folders of the RCC binary, even if the binary is not even a symlink. Note that the unprivileged user has read and execute access to the RCC binary, otherwise, starting RCC in the first place would fail. To solve this issue, we resort to a different no-op in the build step: * Windows: `cmd.exe` Note that it is unclear what commands are actually available here. For example, the echo command is available on Windows systems but cannot be found when used with `rcc task script`. However, inside a shell created with`rcc task shell`, the echo command works (and so does calling the RCC binary). * Linux: `true` Unfortunately, we have no good way of testing if running plans with an unprivileged user works, since we cannot create an additional user session in the GitHub actions. CMK-20071
1 parent ff6f241 commit b47c5dc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/environment.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,12 @@ impl RCCEnvironment {
9898
.add_argument("script");
9999
self.apply_current_settings(&mut build_command_spec);
100100

101-
let mut version_command_spec = Self::bundled_command_spec(&self.binary_path);
102-
version_command_spec.add_argument("-v");
103-
104-
build_command_spec
105-
.add_argument("--")
106-
.add_argument(version_command_spec.executable)
107-
.add_arguments(version_command_spec.arguments);
101+
build_command_spec.add_argument("--").add_argument(
102+
#[cfg(unix)]
103+
"true",
104+
#[cfg(windows)]
105+
"cmd.exe",
106+
);
108107

109108
Some(BuildInstructions {
110109
command_spec: build_command_spec,
@@ -185,9 +184,12 @@ mod tests {
185184
.add_argument("--space")
186185
.add_argument("my_plan")
187186
.add_argument("--")
188-
.add_argument("/bin/rcc")
189-
.add_argument("--bundled")
190-
.add_argument("-v");
187+
.add_argument(
188+
#[cfg(unix)]
189+
"true",
190+
#[cfg(windows)]
191+
"cmd.exe",
192+
);
191193

192194
assert_eq!(
193195
RCCEnvironment {

0 commit comments

Comments
 (0)