-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(cd): on android/termux fails to cd into /sdcard #10329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for your pr, I've leaved some comments, would you please have a look?
@@ -271,7 +271,14 @@ fn have_permission(dir: impl AsRef<Path>) -> PermissionResult<'static> { | |||
} | |||
} | |||
|
|||
#[cfg(unix)] | |||
#[cfg(any(target_os = "linux", target_os = "android"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure for this, the pr is handled for android
, so it should be #[cfg(target_os = "android")]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this works for both linux and android, this implementation of any_group
is more efficient than former one, but i wasn't sure whether osx
comes under linux or not and whether this logic works on osx
or not, so considered for only linux
and android
user_groups.iter().any(|gid| gid.as_raw() == owner_group) | ||
} | ||
|
||
#[cfg(all(unix, not(any(target_os = "linux", target_os = "android"))))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this can be [cfg(all(unix, not(target_os = "android")))]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above, this more efficient way of checking group for linux can done using above implementation so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a setup to validate that this can resolve the access issues for Android but things sound good to me to simplify getting the groups on Linux (without taking the detour of inquiring the username). Implementation looks safe to me,
Don't have the system knowledge to say whether we could do the same on MacOS or the BSDs.
or any directory that user has access via group on android or on linux to check if the user belongs to given directory group, use libc::getgroups function Co-authored-by: Stefan Holderbach <[email protected]> rfmt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thank you for your explanation. Then it looks good to me :-D
And BTW, please don't rebase and force-push the branch during a pr, in case we can track changes in pr more easily :) For more information you can read: https://amtoine.github.io/posts/you-shall-not-rebase/ |
fix on android/termux fails to cd into /sdcard or any directory that user has access via group fixes nushell#8095 I am not aware how this works on other platform so feel free to modify this pr or even close it if it is not correct # Description on android or on linux to check if the user belongs to given directory group, use `libc::getgroups` function # User-Facing Changes NA
fix on android/termux fails to cd into /sdcard or any directory that user has access via group
fixes #8095
I am not aware how this works on other platform so feel free to modify this pr or even close it if it is not correct
Description
on android or on linux to check if the user belongs to given directory group, use
libc::getgroups
functionUser-Facing Changes
NA
Tests + Formatting
After Submitting