Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm: added write-protected check for files #3853

Merged
merged 5 commits into from
Aug 29, 2022

Conversation

stefins
Copy link
Contributor

@stefins stefins commented Aug 20, 2022

Hi,

This fixes #3813. also this doesn't check the permission of directories right now.

@sylvestre
Copy link
Contributor

Looks like it broke a test:

---- test_rm::test_rm_interactive_never stdout ----
current_directory_resolved: 
touch: /tmp/.tmpgyUHXS/test_rm_interactive
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils chmod 0 test_rm_interactive
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils rm --interactive=never test_rm_interactive
thread 'test_rm::test_rm_interactive_never' panicked at 'assertion failed: !at.file_exists(file_2)', /home/runner/work/coreutils/coreutils/tests/by-util/test_rm.rs:348:5

And please add a new test showing that the initial issue is fixed
thanks

@stefins
Copy link
Contributor Author

stefins commented Aug 20, 2022

In this line

InteractiveMode::Never
we are making InteractiveMode::Never as default without any arguments but in case of #3813 we need to be interactive in default mode .

Maybe we can add a new InteractiveMode?

@sylvestre
Copy link
Contributor

Sure, you can do that :)

@stefins stefins force-pushed the rm-write-protected branch 2 times, most recently from e15292c to ad4eac8 Compare August 23, 2022 15:47
@tertsdiepraam
Copy link
Member

I'm not sure about this, but it sounds like this issue is separate from the existing InteractiveMode. I.e. there is prompting for recursive removal and for removal of protected files. If they are linked I would like the naming to be a bit more descriptive than Default, maybe PromptProtected or something like that (I'm sure there's a better name).

@stefins
Copy link
Contributor Author

stefins commented Aug 23, 2022

@tertsdiepraam Ok I'll change the name to PromptProtected

@sylvestre
Copy link
Contributor

Fails on windows

failures:

---- test_rm::test_prompt_write_protected_no stdout ----
current_directory_resolved: 
touch: C:\Users\RUNNER~1\AppData\Local\Temp\.tmp0yZTql\test_rm_prompt_write_protected_2
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe rm test_rm_prompt_write_protected_2
thread 'test_rm::test_prompt_write_protected_no' panicked at 'assertion failed: at.file_exists(file_2)', D:\a\coreutils\coreutils\tests\by-util\test_rm.rs:394:5


failures:
    test_rm::test_prompt_write_protected_no

@sylvestre
Copy link
Contributor

@stefins stefins force-pushed the rm-write-protected branch from 96ef64d to 7644911 Compare August 27, 2022 09:58
@stefins
Copy link
Contributor Author

stefins commented Aug 27, 2022

@sylvestre removed the failing test!

@sylvestre
Copy link
Contributor

@stefins why did you remove it ?

@stefins
Copy link
Contributor Author

stefins commented Aug 27, 2022

It was failing on all the OS's!

Edit: Also we have another test to test the function

@stefins stefins requested a review from sylvestre August 27, 2022 10:48
@sylvestre
Copy link
Contributor

sure but it is an issue with the test or with the code ?
was it failing on linux too ?

@stefins
Copy link
Contributor Author

stefins commented Aug 27, 2022

Yeah It was failing on ubuntu also but only on these jobs

Build/stable (ubuntu-latest, feat_os_unix)
Build/stable (macos-latest, feat_os_macos)
Build/stable (windows-latest, feat_os_windows)
Build/nightly (ubuntu-latest, feat_os_unix)
Build/nightly (macos-latest, feat_os_macos)
Build/nightly (windows-latest, feat_os_windows)

https://github.com/uutils/coreutils/actions/runs/2913039044

@tertsdiepraam
Copy link
Member

Seems like the cfg(feature = chmod) should apply to the test signature instead of just the single line. Otherwise it will fail on all platforms that don't have chmod enabled. Maybe that fixes the test?

@stefins stefins force-pushed the rm-write-protected branch from 7644911 to 4c1c9eb Compare August 27, 2022 14:07
@stefins
Copy link
Contributor Author

stefins commented Aug 27, 2022

@tertsdiepraam done

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it worked! I think it looks good now but I'll leave the final check to Sylvestre

@sylvestre
Copy link
Contributor

Almost ready, the error message isn't exactly the same in the CI with the GNU testsuite:


2022-08-27T15:00:12.1685929Z 
2022-08-27T15:00:12.1686024Z FAIL: tests/rm/isatty
2022-08-27T15:00:12.1686231Z =====================
2022-08-27T15:00:12.1686342Z 
2022-08-27T15:00:12.1686519Z --- exp	2022-08-27 14:25:17.743717230 +0000
2022-08-27T15:00:12.1686821Z +++ out	2022-08-27 14:25:17.743717230 +0000
2022-08-27T15:00:12.1687062Z @@ -1 +1 @@
2022-08-27T15:00:12.1687367Z -rm: remove write-protected regular empty file 'f'? x
2022-08-27T15:00:12.1687716Z +rm: remove write-protected file 'f'? x
2022-08-27T15:00:12.1687985Z FAIL tests/rm/isatty.sh (exit status: 1)

https://pipelines.actions.githubusercontent.com/serviceHosts/91055393-6e6f-4662-ba97-3acee74a8c7c/_apis/pipelines/1/runs/16689/signedlogcontent/4?urlExpires=2022-08-29T11%3A35%3A26.1596317Z&urlSigningMethod=HMACV1&urlSignature=vjqV0OfnErkx%2BuWWQjyk6BXKVEkNlSy9i7NYUjHwAnc%3D

@stefins
Copy link
Contributor Author

stefins commented Aug 29, 2022

@sylvestre the test seems to be failing in the main branch also

@sylvestre
Copy link
Contributor

Not sure what you mean but it works here:

Warning: Congrats! The gnu test tests/rm/isatty is no longer failing!

@stefins
Copy link
Contributor Author

stefins commented Aug 29, 2022

@sylvestre
Copy link
Contributor

sylvestre commented Aug 29, 2022

oh that, don't bother ;)
we have intermittent issues in the CI

@sylvestre sylvestre merged commit 282774a into uutils:main Aug 29, 2022
@stefins stefins deleted the rm-write-protected branch August 29, 2022 15:09
@sylvestre
Copy link
Contributor

well done ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rm write-protected check is missing
3 participants