Skip to content

Commit c9bcc93

Browse files
authored
Make creating symlinks and hardlinks count as a read operation (#364)
Although this might let you launder writes to files through the symlink, that can be something that the `onWrite` callback checks if necessary
1 parent ff52a8b commit c9bcc93

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

os/src/FileOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ object exists extends Function1[Path, Boolean] {
366366
object hardlink {
367367
def apply(link: Path, dest: Path) = {
368368
checker.value.onWrite(link)
369-
checker.value.onWrite(dest)
369+
checker.value.onRead(dest)
370370
Files.createLink(link.wrapped, dest.wrapped)
371371
}
372372
}
@@ -377,7 +377,7 @@ object hardlink {
377377
object symlink {
378378
def apply(link: Path, dest: FilePath, perms: PermSet = null): Unit = {
379379
checker.value.onWrite(link)
380-
checker.value.onWrite(dest match {
380+
checker.value.onRead(dest match {
381381
case p: RelPath => link / RelPath.up / p
382382
case p: SubPath => link / RelPath.up / p
383383
case p: Path => p

os/test/src/CheckerTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ object CheckerTests extends TestSuite {
278278
}
279279
}
280280
test("hardlink") - prepChecker { wd =>
281-
intercept[WriteDenied] {
281+
intercept[ReadDenied] {
282282
os.hardlink(wd / "Linked.txt", rd / "File.txt")
283283
}
284284
os.exists(wd / "Linked.txt") ==> false

0 commit comments

Comments
 (0)