Skip to content

Commit

Permalink
fix: remove misleading 'rm' error message (#10)
Browse files Browse the repository at this point in the history
Problem:
 When running a Session as a different user on posix systems you will
see a benign, but misleading, error message in the log that looks like:
```
rm: cannot remove '/tmp/openjd/session-name': Permission denied
```

This is caused by our two-phase cleanup of the Session working
directory. We start with a cross-user 'rm -rf' to delete everything in
the directory, and then do a same-user recursive delete. So, the working
directory is getting cleaned up but there is this error in logs that is
misleading.

Solution:
 The `rm -rf` just needs to be changed to `rm -rf <dir>/*` from `rm -rf
<dir>`.

Signed-off-by: Daniel Neilson <[email protected]>
  • Loading branch information
ddneilson authored Sep 13, 2023
1 parent 19431ab commit e25a41e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ build = "hatch build"

[envs.codebuild.env-vars]
PIP_INDEX_URL=""

[envs.container.env-vars]

2 changes: 1 addition & 1 deletion src/openjd/sessions/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def cleanup(self) -> None:
if os_name == "posix":
subprocess = LoggingSubprocess(
logger=self._logger,
args=["rm", "-rf", str(self.working_directory)],
args=["rm", "-rf", f"{str(self.working_directory)}/*"],
user=self._user,
)
# Note: Blocking call until the process has exited
Expand Down
4 changes: 2 additions & 2 deletions testing_containers/ldap_sudo_environment/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ cd code
python -m venv .venv
source .venv/bin/activate
pip install hatch
# Use the codebuild env so that PIP_INDEX_URL isn't set in the hatch config files.
hatch run codebuild:test
# Use the container env so that PIP_INDEX_URL isn't set in the hatch config files.
hatch run container:test
4 changes: 2 additions & 2 deletions testing_containers/localuser_sudo_environment/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ cd code
python -m venv .venv
source .venv/bin/activate
pip install hatch
# Use the codebuild env so that PIP_INDEX_URL isn't set in the hatch config files.
hatch run codebuild:test
# Use the container env so that PIP_INDEX_URL isn't set in the hatch config files.
hatch run container:test

0 comments on commit e25a41e

Please sign in to comment.