Skip to content

Commit 81e20d0

Browse files
committed
fix: 🐛 update RENAME behavior
1 parent 9de370f commit 81e20d0

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/nfs/v4/server/operations/node/Nfsv4OperationsNode.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,12 +1159,8 @@ export class Nfsv4OperationsNode implements Nfsv4Operations {
11591159
const oldFull = NodePath.join(savedPathAbsolute, request.oldname);
11601160
const newFull = NodePath.join(currentPathAbsolute, request.newname);
11611161
if (oldFull.length < this.dir.length || newFull.length < this.dir.length) throw Nfsv4Stat.NFS4ERR_NOENT;
1162-
// Ensure both paths are inside the server root. If target escapes, return XDEV.
1163-
if (!(oldFull === this.dir || oldFull.startsWith(this.dir + NodePath.sep)))
1164-
return new msg.Nfsv4RenameResponse(Nfsv4Stat.NFS4ERR_XDEV);
1165-
if (!(newFull === this.dir || newFull.startsWith(this.dir + NodePath.sep)))
1166-
return new msg.Nfsv4RenameResponse(Nfsv4Stat.NFS4ERR_XDEV);
1167-
// Now map to absolute paths (this.absolutePath will validate existence and path)
1162+
if (!oldFull.startsWith(this.dir)) return new msg.Nfsv4RenameResponse(Nfsv4Stat.NFS4ERR_NOENT);
1163+
if (!newFull.startsWith(this.dir)) return new msg.Nfsv4RenameResponse(Nfsv4Stat.NFS4ERR_NOENT);
11681164
let oldPath: string;
11691165
let newPath: string;
11701166
try {

src/nfs/v4/server/operations/node/__tests__/RENAME.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('RENAME operation', () => {
1616
vol.writeFileSync('/export/file.txt', 'data');
1717
// Simulate EXDEV by calling rename with invalid target outside export
1818
const res = await client.compound([nfs.PUTROOTFH(), nfs.SAVEFH(), nfs.RENAME('file.txt', '../outside.txt')]);
19-
expect(res.status).toBe(Nfsv4Stat.NFS4ERR_XDEV);
19+
expect(res.status).toBe(Nfsv4Stat.NFS4ERR_NOENT);
2020
await stop();
2121
});
2222
});

0 commit comments

Comments
 (0)