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 no-pty-setowner option in authorized_keys #272

Closed
wants to merge 1 commit into from
Closed

add no-pty-setowner option in authorized_keys #272

wants to merge 1 commit into from

Conversation

rd235
Copy link

@rd235 rd235 commented Jan 7, 2024

My goal is to use dropbear to log-in into unprivileged network namespaces (like those created by vdens: https://github.com/rd235/vdens )

Dropbear's pty supports fails as in unprivileged namespaces the group ownership of /dev/pty/* is remapped to "nogroup" (instead of "tty"). So the condition in sshpty.c:

385   if (st.st_uid != pw->pw_uid || !(st.st_gid == gid || st.st_gid == pw->pw_gid)) {

is true, and then it tries to chown the pty file:

386     if (chown(tty_name, pw->pw_uid, gid) < 0) {

... the session fails because it would require CAPCHOWN that the unprivileged namespace does not own.

There is no need to change the pty ownership for this application (outside a namespace the condition of line 385 would have been false. It is true only due to the gid remapping.)

This pull request defines a new option for the authorized_keys file named "no-pty-setowner". When this option is defined dropbear skips the owner redefinition of the pty special file.

This option enables one further application case for dropbear. Other usages are unaffected (not using the new "no-pty-setowner" option)

@mkj
Copy link
Owner

mkj commented Jan 22, 2024

Dropbear's pty supports fails as in unprivileged namespaces the group ownership of /dev/pty/* is remapped to "nogroup" (instead of "tty"). So the condition in sshpty.c:

To me it seems like like the correct fix would be to ensure /dev/pts is mounted nogroup. My understanding is that it's best for each namespace to have its own /dev/pts mountpoint, so that could be mounted with uid= option set to the tty user uid.

@mkj
Copy link
Owner

mkj commented Jan 22, 2024

Sorry, I mean "ensure /dev/pts is not owned by nogroup"

@rd235
Copy link
Author

rd235 commented Jan 22, 2024

OK. you are right. This problem can have a simpler solution. I'll file a new pull request.

@rd235 rd235 closed this Jan 22, 2024
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.

2 participants