copy icon indicating copy to clipboard operation
copy copied to clipboard

another recursive copy

Open enthor opened this issue 3 years ago • 6 comments

Copy("test/data.copy", "test/data.copy/alltestdata")

Note: when I found the alltestdata and deleted it, MacOS refused to empty the trash because "pathname too long". I tried sudo rm etc but "invalid operation". So the solution if cannot empty trash: drag items out of trash to, say, Downloads and then just "rm" them.

enthor avatar Apr 15 '21 19:04 enthor

that's circular reference

otiai10 avatar Apr 16 '21 00:04 otiai10

yes. i am validating in my fork to prevent it. happened accidentally during testing and caused problems.

5

On Apr 15, 2021, at 5:43 PM, Hiromu OCHIAI @.***> wrote:

 that's circular reference

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

enthor avatar Apr 16 '21 00:04 enthor

Let me clarify your point. Do you mean we, the package, should detect circular reference on behalf of package users?

otiai10 avatar Apr 16 '21 00:04 otiai10

i believe so. things which cause problems... like an algorithm that runs for 8 hours in certain cases, for example, always come back to the programmer. imagine creating a Doomsday Device. It must not go off accidentally because that is bad:)

5

On Apr 15, 2021, at 5:55 PM, Hiromu OCHIAI @.***> wrote:

 Let me clarify your point. Do you mean we, the package, should detect circular reference on behalf of package users?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

enthor avatar Apr 16 '21 01:04 enthor

yes⛳️

copy dir list first.

that does not solve all problems but some! i am doing that in my experimental fork. could be done in otiai.copy at no cost, just switch sequence of stmts.

still...

malicious symlinks cannot always be defeated though, and eventually pathname length exceeds os limit. so for safety, skip symlinks by default. there are no symlinks in /usr/local/go, for example, and they are uncommon in applications programming, i think.

5

On Apr 21, 2021, at 1:17 AM, Jason Shi @.***> wrote:

 Encounter the same issue.

folder -> folder/copy My guess is that: During the folder list (it is dynamic), it will contain copy folder which will result in infinite folder reference.

Fix suggestion: make sure the list is dynamic, list it before copy folder is created.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

enthor avatar Apr 21 '21 08:04 enthor

ok, i defeated malicious symlinks - as far as I know.

see github.com/enthor/kmdrv0/kopy#testSkipBrokenSymlinks()

and test/data/broken/README.txt

The only "broken" symlinks which may safely be skipped are of the variety:

errors.Is(err, os.ErrNotExist)

Other os.Stat() errors -- when treating the Symlink as just a file -- cannot be skipped safely because they may be of the variety "too many symlinks". The process must be halted at that point, but at least the program errors out and not the OS or a golang function, so the code would appear to be safe from a hacker installing a malicious symlink.

enthor avatar Apr 22 '21 02:04 enthor