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

✨ add disable option for permission #882

Merged
merged 2 commits into from Sep 20, 2023

Conversation

zwpaper
Copy link
Member

@zwpaper zwpaper commented Aug 28, 2023

add an option for permission args to disable the detection of owner and permission,
it may be used in Windows to speed up.

a temporary fix for #200

this is a POC or RFC, any comment is welcome!


TODO

  • Use cargo fmt
  • Add necessary tests
  • Add changelog entry
  • Update default config/theme in README (if applicable)
  • Update man page at lsd/doc/lsd.md (if applicable)

@muniu-bot
Copy link

muniu-bot bot commented Aug 28, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zwpaper

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@domsleee
Copy link
Contributor

This is what the output looks like

❯ cargo run -- --long
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s
     Running `target\debug\lsd.exe --long`
lsd: .: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\build.rs: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\Cargo.lock: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\Cargo.toml: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\CHANGELOG.md: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\ci: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\CODEOWNERS: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\doc: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\LICENSE: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\README.md: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\rustfmt.toml: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\src: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\target: The specified domain either does not exist or could not be contacted. (os error 1355)

lsd: .\tests: The specified domain either does not exist or could not be contacted. (os error 1355)

.????????? ? ? 1.8 KB Tue Sep 12 14:47:32 2023  build.rs
.????????? ? ?  39 KB Fri Sep 15 22:24:29 2023  Cargo.lock
.????????? ? ? 1.9 KB Fri Sep 15 22:24:29 2023  Cargo.toml
.????????? ? ?  20 KB Fri Sep 15 22:24:29 2023  CHANGELOG.md
d????????? ? ?   0 B  Tue Sep 12 14:47:32 2023  ci
.????????? ? ?  35 B  Tue Sep 12 14:47:32 2023  CODEOWNERS
d????????? ? ?   0 B  Tue Sep 12 14:47:32 2023  doc
.????????? ? ?  11 KB Tue Sep 12 14:47:32 2023  LICENSE
.????????? ? ?  20 KB Fri Sep 15 22:24:29 2023  README.md
.????????? ? ? 181 B  Tue Sep 12 14:47:32 2023  rustfmt.toml
d????????? ? ? 4.0 KB Fri Sep 15 22:24:29 2023  src
d????????? ? ?   0 B  Tue Sep 12 14:48:03 2023  target
d????????? ? ?   0 B  Tue Sep 12 14:47:32 2023  tests

Perhaps we can provide a hint to the user, e.g.

This can be caused by network issues when contacting a remote domain, try disabling permissions with --permission disable

I'm still thinking the mode attributes should be default for windows (#866 (comment)), ACL seems like a bad default because it isn't safe
Like --permission could be

  • rwx (default); which is rwx on linux and mode attributes on windows
  • octal: octal on linux, mode attributes on windows

Then we could have a separate --permission-windows-acl flag as an unsafe option, e.g. for users not on a domain or with an ACL setup that doesn't require files from a remote machine.

@zwpaper
Copy link
Member Author

zwpaper commented Sep 15, 2023

hi @domsleee, thanks for the advice!

Honestly, I am not a Windows user, so your suggestion(or other Windows users) would be valuable to me.

I was trying to add the ability to disable permission detection on Windows in this PR, first, let me make sure that this works in your view.

and for the default options for windows, how about we try and disable it automatically if errors occur, this seems more to be intelligent.

src/meta/mod.rs Outdated
match windows_utils::get_file_data(path) {
Ok((owner, permissions)) => (Some(owner), Some(permissions)),
Err(e) => {
eprintln!("lsd: {}: {}\n", path.to_str().unwrap_or(""), e);
Copy link
Contributor

@domsleee domsleee Sep 16, 2023

Choose a reason for hiding this comment

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

I think a hint here could help users:

❯ lsd
let hint = if e.raw_os_error() == Some(ERROR_NO_SUCH_DOMAIN) {
    " Hint: Consider using `--permission disable`."
} else {
    ""
};

Outputs:

lsd: .: The specified domain either does not exist or could not be contacted. (os error 1355). Hint: Consider using `--permission disable`.

lsd: .\build.rs: The specified domain either does not exist or could not be contacted. (os error 1355). Hint: Consider using `--permission disable`.

lsd: .\Cargo.lock: The specified domain either does not exist or could not be contacted. (os error 1355). Hint: Consider using `--permission disable`.

lsd: .\Cargo.toml: The specified domain either does not exist or could not be contacted. (os error 1355). Hint: Consider using `--permission disable`.

@domsleee
Copy link
Contributor

I was trying to add the ability to disable permission detection on Windows in this PR, first, let me make sure that this works in your view.

From my perspective, the --permission disable fixes the performance issue and stops the errors coming up, so this is a good fix 👍

and for the default options for windows, how about we try and disable it automatically if errors occur, this seems more to be intelligent.

Yeah, it could be an idea to show only the first time 1355 occurs, so that the output is less noisy.

There are two cases

  1. GetEffectiveRightsFromAclW can't access the domain, and os error 1355 is thrown
  2. GetEffectiveRightsFromAclW works, but it can be very slow when the information about permissions requires files from a remote server

Case 1 is fixed by the error handling in your PR, but case 2 is why I'm suggesting that ACL shouldn't be default 👍

@zwpaper
Copy link
Member Author

zwpaper commented Sep 18, 2023

hi @domsleee, it sounds reasonable to not make it as default for Windows, let me finish this PR, and maybe you can try to implement the rest two?

and you could create 2 issues to track them.

Signed-off-by: Wei Zhang <kweizh@gmail.com>
Signed-off-by: Wei Zhang <kweizh@gmail.com>
@codecov-commenter
Copy link

Codecov Report

Merging #882 (53e333d) into master (bfbb217) will decrease coverage by 0.18%.
The diff coverage is 82.45%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master     #882      +/-   ##
==========================================
- Coverage   85.93%   85.75%   -0.18%     
==========================================
  Files          51       51              
  Lines        4962     5005      +43     
==========================================
+ Hits         4264     4292      +28     
- Misses        698      713      +15     
Files Changed Coverage Δ
src/app.rs 33.33% <ø> (ø)
src/config_file.rs 72.72% <ø> (ø)
src/core.rs 0.00% <0.00%> (ø)
src/theme/color.rs 76.92% <ø> (ø)
src/meta/owner.rs 83.72% <33.33%> (-3.78%) ⬇️
src/meta/mod.rs 55.07% <61.11%> (-0.07%) ⬇️
src/display.rs 83.23% <100.00%> (ø)
src/flags/blocks.rs 96.27% <100.00%> (ø)
src/flags/ignore_globs.rs 94.44% <100.00%> (-0.11%) ⬇️
src/flags/permission.rs 98.24% <100.00%> (+0.20%) ⬆️
... and 7 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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

Successfully merging this pull request may close these issues.

None yet

3 participants