You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[22261112919, Job 64399507098](https://github.com/link-foundation/sandbox/actions/runs/22261112919/job/64399507098) — First failure: "No such file or directory"
6
+
-[22263724056](https://github.com/link-foundation/sandbox/actions/runs/22263724056/job/64405913545) — Second failure: "Permission denied"
The "Measure Disk Space and Update README" workflow failed with:
13
+
This issue has two related but distinct failures:
14
+
15
+
### First Failure (Run 22261112919) — "No such file or directory"
11
16
12
17
```
13
18
cat: data/disk-space-measurements.json: No such file or directory
14
19
##[error]Process completed with exit code 1.
15
20
```
16
21
17
-
The root cause is that `su - sandbox` (login shell) changes the working directory to the sandbox user's home (`/home/sandbox`). The relative path `data/disk-space-measurements.json` then resolves to `/home/sandbox/data/disk-space-measurements.json` — a file that was never created there. The JSON file was correctly initialized in the runner's working directory (`/home/runner/work/sandbox/sandbox/data/disk-space-measurements.json`), but the sandbox-measure.sh script tried to read and write a different file.
22
+
Root cause: `su - sandbox` (login shell) changes CWD to `/home/sandbox`. The relative path `data/disk-space-measurements.json` then resolves to `/home/sandbox/data/disk-space-measurements.json` — a path that was never created. **Fix**: Convert the relative JSON path to an absolute path using `realpath` before passing to `su - sandbox`. Applied in PR #47 (v1.3.5).
18
23
19
-
**Fix**: Convert the relative JSON output path to an absolute path before passing it to `su - sandbox`.
24
+
### Second Failure (Run 22263724056) — "Permission denied"
Root cause: After applying the `realpath` fix, the absolute path was passed correctly, but the sandbox user still could not access the file. The GitHub Actions workspace directory `/home/runner/work/sandbox/sandbox/` is owned by `runner` and has permissions `750`, denying traverse access to the `sandbox` user (who is not in the `runner` group). The first fix granted `o+rx` only to the immediate parent `data/` directory, but not to the workspace root — so the kernel path traversal check still failed at `/home/runner/work/sandbox/sandbox/`. **Fix**: Copy the JSON file to `/tmp/` (world-accessible, mode `1777`) before running the sandbox user script, then copy it back. Applied in v1.3.6.
20
32
21
33
## Timeline of Events
22
34
@@ -97,13 +109,14 @@ This directory (`/home/sandbox/data/`) was never created, making the path comple
97
109
98
110
## Solution
99
111
100
-
### Fix: Convert to Absolute Path Before `su - sandbox`
112
+
### Fix 1 (v1.3.5, PR #47): Convert to Absolute Path Before `su - sandbox`
101
113
102
-
The fix is to resolve the JSON output path to an absolute path before executing the sandbox user's sub-script. This ensures the path remains valid regardless of what working directory the sub-shell starts in.
114
+
Resolve the JSON output path to an absolute path before executing the sandbox user's sub-script. This ensures the path remains valid regardless of what working directory the sub-shell starts in.
103
115
104
116
```bash
105
-
# Convert JSON_OUTPUT_FILE to absolute path before passing to su
su - sandbox -c "bash /tmp/sandbox-measure.sh '$JSON_OUTPUT_FILE_ABS'"
@@ -112,28 +125,54 @@ else
112
125
fi
113
126
```
114
127
115
-
Additionally, the `sandbox-measure.sh` script needs to create the parent directory if it doesn't exist, since the sandbox user may not have the `data/` directory in their home:
128
+
This resolved the "No such file or directory" error but not the "Permission denied" error.
129
+
130
+
### Fix 2 (v1.3.6, PR #48): Copy JSON File to `/tmp/` for Sandbox User Access
131
+
132
+
The deeper problem is that the sandbox user cannot traverse the workspace directory tree. The GitHub Actions workspace root (`/home/runner/work/sandbox/sandbox/`) is owned by `runner` with permissions `750`. The `sandbox` user is not in the `runner` group, so they get `EACCES` when trying to traverse the directory — even if the file itself is world-readable.
133
+
134
+
The fix copies the JSON file to `/tmp/` (world-accessible, mode `1777`), runs the sandbox user script against that copy, then copies it back:
For the sandbox user to access a file at `/home/runner/work/sandbox/sandbox/data/measurements.json`, they need execute (`x`) permission on **every directory** in the path:
155
+
156
+
| Directory | Owner | Typical mode | Sandbox user can traverse? |
|`/home/runner/work/sandbox/sandbox/`| runner |**750**|**No** (no world x) |
162
+
|`.../data/`| root | was set to o+rx by Fix 1 | Yes |
163
+
|`.../measurements.json`| root | was set to o+rw by Fix 1 | Yes |
123
164
124
-
-`realpath` converts relative paths to absolute paths using the current working directory
125
-
- The absolute path `/home/runner/work/sandbox/sandbox/data/disk-space-measurements.json` is unambiguous and valid from any working directory
126
-
- The sandbox user needs write access to this path — since the runner runs with elevated privileges and the outer script (running as root) creates the file, the sandbox user needs read/write access, which can be ensured by pre-creating the file with appropriate permissions
165
+
Fix 1 set `o+rx` on `data/` and `o+rw` on the file but missed `/home/runner/work/sandbox/sandbox/` which has no world-execute bit. Fix 2 sidesteps the issue entirely by using `/tmp/` which is world-accessible (`1777`).
127
166
128
167
### Alternative Approaches Considered
129
168
130
-
1.**Use `su` without `-`** (no login shell): Would preserve the working directory but break user-space tool installations that expect a clean home environment. Not recommended.
169
+
1.**Walk all ancestor directories and chmod**: `chmod o+rx` every directory from `/` to `data/`. This works but widens permissions on runner-owned directories unnecessarily and has a larger blast radius.
131
170
132
-
2.**Pass absolute path directly from CLI**: Requires users to always specify absolute paths in the workflow, which is error-prone.
171
+
2.**Use `su` without `-`** (no login shell): Would preserve the working directory but break user-space tool installations that expect a clean home environment. Not recommended.
133
172
134
-
3.**Use `cd` inside `su -` command**: Adding `cd /path/to/workdir &&` before the script call would work but is fragile.
173
+
3.**Pass absolute path directly from CLI**: Requires users to always specify absolute paths in the workflow, which is error-prone.
135
174
136
-
4.**Write JSON to `/tmp/` instead of `data/`**: Would avoid the working directory issue but changes the documented output location.
175
+
4.**Use `cd` inside `su -` command**: Adding `cd /path/to/workdir &&` before the script call would work but is fragile.
0 commit comments