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

sudo-rs in a clean chroot isn't behaving properly #805

Closed
sylvestre opened this issue Nov 20, 2023 · 2 comments · Fixed by #807
Closed

sudo-rs in a clean chroot isn't behaving properly #805

sylvestre opened this issue Nov 20, 2023 · 2 comments · Fixed by #807
Assignees
Labels
C-exec Execution component (interfacing with OS) enhancement New feature or request

Comments

@sylvestre
Copy link
Contributor

with a new chroot, sudo-rs is doing some unexpected thing.

$ /root/.cargo/bin/sudo --version
sudo-rs 0.2.1

$ /root/.cargo/bin/sudo ls
sudo-rs: cannot execute '/usr/bin/ls': No such device (os error 19)

  1. create a chroot
  2. cargo install sudo-rs
  3. Create a sudoer file
  4. /root/.cargo/bin/sudo ls
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults        env_keep+="DEB_* BUILD* PATH OTHERMIRROR EXTRAPACKAGES"
# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
@sylvestre sylvestre added the bug Something isn't working label Nov 20, 2023
@squell squell added C-exec Execution component (interfacing with OS) enhancement New feature or request and removed bug Something isn't working labels Nov 28, 2023
@squell
Copy link
Collaborator

squell commented Nov 28, 2023

After some digging, this seems related to the use_pty behaviour, which is the default for sudo-rs.

If you put Defaults !use_pty in /etc/sudoers (in the chroot), sudo-rs does work as you expect. On the other hand, if you use Defaults use_pty, you get the same problem with original sudo (although a slightly better error message):

# sudo ls
sudo: unable to allocate pty: No such device

I.e. this seems not really a bug but more an issue of the chroot environment being too limited for both sudo and sudo-rs to safely perform their intended function.

@squell squell self-assigned this Nov 28, 2023
@rnijveld
Copy link
Collaborator

Specifically it appears that /dev/ptmx is not the proper pseudo terminal multiplexer device that it is supposed to be when using debootstrap, it might be a bug in the way debootstrap sets up the chroot.

@squell squell linked a pull request Nov 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-exec Execution component (interfacing with OS) enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants