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

cd builtin doesn't work if your group doesn't match the directory's group #1033

Closed
theclapp opened this issue Sep 27, 2023 · 0 comments · Fixed by #1034
Closed

cd builtin doesn't work if your group doesn't match the directory's group #1033

theclapp opened this issue Sep 27, 2023 · 0 comments · Fixed by #1034

Comments

@theclapp
Copy link
Collaborator

The cd builtin checks whether your user ID can read a directory, or whether your actual group ID can read a directory, or whether "others" can read a directory, but it doesn't check the other groups your ID may be a member of.

% id
uid=1001(lmc) gid=1001(lmc) groups=1001(lmc),27(sudo),998(vboxsf)

% ls -ld host
drwxrwx--- 1 root vboxsf 640 Sep 16 03:48 host/

% cd host
=> error 1

It looks like you need to check user.User.GroupIds() (https://pkg.go.dev/os/user#User.GroupIds) too/instead.

theclapp added a commit to theclapp/sh that referenced this issue Sep 27, 2023
theclapp added a commit to theclapp/sh that referenced this issue Sep 27, 2023
mvdan pushed a commit that referenced this issue Sep 30, 2023
Rip out the body of interp.hasPermissionToDir and replace it with just a
call to unix.Access(path, unix.X_OK).

Update the function signature of hasPermissionToDir in os_notunix.go,
too.

Fixes #1033.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant