Repository navigation
prevent tunnel sockets from overwriting existing files - #1141
shizuku198411 wants to merge 6 commits into
Conversation
|
I think we should overwrite the file if it's another socket; it could be left over from another session that closed abruptly. But if it's a regular file we should probably avoid deleting it, yes. |
|
I agree, allowing existing sockets to be overwritten makes sense. |
|
|
||
| if realDir == user.HomeDir || strings.HasPrefix(realDir, user.HomeDir+"/") { | ||
| return nil | ||
| return checkSocketPath(listen.Address) |
There was a problem hiding this comment.
I think this doesn't really fit into the purpose of authorizePath, can we move it up to the call site?
It also only applies to files on the host; is it possible to apply the same logic to files inside the workshop?
There was a problem hiding this comment.
Thank you for the review. you're right, the file check doesn't belong in authorizePath(). I've moved it to the call site, where it now runs as a separate validation step.
I also confirmed that existing files can be overwritten inside the workshop.
However, since this involves a manually established connection, it follows a different code path.
I'll look into the appropriate place to add the same protection.
jonathan-conder
left a comment
There was a problem hiding this comment.
maybe we can move the original checkSocketPath into the backend Setup as well? similar to how mounts create directories on the host and in the workshop.
I made changes here recently so there may be some merge conflicts, sorry!
f5bfc75 to
d37daad
Compare
|
@jonathan-conder I’ve moved the host-side check into the backend |
Description
Fixes #1140
Prevent the tunnel interface from overwriting existing files when creating a Unix socket.
Previously, Workshop could replace an existing regular file with a Unix socket during tunnel setup, potentially causing data loss.
This PR adds an
os.Lstat()check to reject socket creation if the target path already exists, regardless of its file type.Changes:
Verification:
start,stop, andrefreshcontinue to work as expected.Self-review quick check
Docs