Skip to content

Wrong owner in /dev/pts #1016

Closed
Closed

Description

@Gavus

Describe the bug
My /dev/pts/ inside a toolbox have the owner set as root. Outside of toolbox they are owned by my user.

Steps how to reproduce the behaviour

  1. Enter a running toolbox with at least two sessions.
  2. Start python3.
  3. Enter: "import io; tty=io.TextIOWrapper(open("/dev/pts/x", "r+b", buffering=0))" (replace x with one of the session numbers).

Expected behaviour
No error.

Actual behaviour
"PermissionError: [Errno 13] Permission denied: '/dev/pts/x'.

Output of toolbox --version (v0.0.90+)
toolbox version 0.0.99.3

Toolbox package info (Github)
tag 0.0.99.3

Output of podman version
e.g.,

Version:            3.0.1
RemoteAPI Version: ?
Go Version:         ?
OS/Arch:            linux/amd64
``

**Info about your OS**
Debian 11 (bullseye)

**Additional context**
I noticed this problem when using the python debugger module pudb, wanting to display the tui in another terminal.

Activity

  1. added
    1. Bug
    on Feb 25, 2022
  2. Ramblurr commented on Dec 8, 2022

    @Ramblurr

    This also prevents the use of emacsclient --tty:

    $ emacsclient --tty
    *ERROR*: Could not open file: /dev/pts/1
    $ sudo chown ramblurr /dev/pts/1
    $ emacsclient --tty
    <emacs opens>
    

    For my system:

    toolbox --version
    toolbox version 0.0.99.3
    
    podman version
    Client:       Podman Engine
    Version:      4.3.1
    API Version:  4.3.1
    Go Version:   go1.19.2
    Built:        Fri Nov 11 16:01:27 2022
    OS/Arch:      linux/amd64
    
    • OS: Fedora Silverblue 37
    • podman package: podman-4.3.1-1.fc37.x86_64
    • toolbox package: toolbox-0.0.99.3-7.fc37.x86_64
  3. swick commented on Feb 20, 2023

    @swick
    Contributor

    This also prevents the mutter kvm test suit from running:

    qemu-system-x86_64: -chardev file,id=console,path=/proc/self/fd/2

    @debarshiray

  4. debarshiray commented on Mar 6, 2023

    @debarshiray
    Member

    I filed containers/crun#1158 for some clarifications and advice.

  5. debarshiray commented on Mar 8, 2023

    @debarshiray
    Member

    I filed containers/podman#17701 for some clarifications and advice.

    That got renamed to containers/crun#1158

  6. debarshiray commented on Mar 8, 2023

    @debarshiray
    Member

    The original problem reported with Python does appear to be solved by PR containers/crun#1159 that's linked from the above podman/crun issue:

    ⬢[rishi@toolbox ~]$ tty
    /dev/pts/0
    ⬢[rishi@toolbox ~]$ 
    ⬢[rishi@toolbox ~]$ ls -l /dev/pts
    total 0
    crw--w----. 1 rishi tty  136, 0 Mar  8 21:21 0
    crw-rw-rw-. 1 root  root   5, 2 Mar  8 21:07 ptmx
    ⬢[rishi@toolbox ~]$ 
    ⬢[rishi@toolbox ~]$ python3
    Python 3.10.8 (main, Nov 14 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import io; tty=io.TextIOWrapper(open("/dev/pts/0", "r+b", buffering=0))
    >>> 
    
  7. debarshiray commented on Mar 8, 2023

    @debarshiray
    Member

    This also prevents the use of emacsclient --tty:

    $ emacsclient --tty
    *ERROR*: Could not open file: /dev/pts/1
    $ sudo chown ramblurr /dev/pts/1
    $ emacsclient --tty
    <emacs opens>
    

    I suspect that this is similar to the problem @dustymabe has been facing with gpg-agent and pinentry in #568

    Even if you fix the user ownership of the pseudo-terminal device (ie., the output of tty(1)), running emacsclient --tty inside the container doesn't open Emacs in the same terminal. Instead it opens it on a different host terminal whose tty(1) accidentally happens to match the container's.

    I use Emacs, but not in a server-client mode, so I am not entirely sure, but I think that the client should open in the same terminal where I typed emacsclient --tty. At least that's what happens on the host.

    It's an accident because the pseudo-terminal devices inside the container aren't the same as on the host. They are totally different because the container has it's own devpts file system at /dev/pts within its mount and user namespaces.

  8. debarshiray commented on Mar 8, 2023

    @debarshiray
    Member

    This also prevents the mutter kvm test suit from running:

    qemu-system-x86_64: -chardev file,id=console,path=/proc/self/fd/2

    Does containers/crun#1159 help?

    I can try to run the mutter test suite myself, but it will take some time. :)

  9. swick commented on Mar 8, 2023

    @swick
    Contributor

    Always fun to test stuff like this on silverblue. Yes, works like a charm. Thanks!

  10. debarshiray commented on Mar 9, 2023

    @debarshiray
    Member

    Always fun to test stuff like this on silverblue. Yes, works like a charm. Thanks!

    Yes, I can imagine. I locally rebuild the RPM with the relevant patch and force it onto my base image. :P

    Thanks for testing it, @swick !

  11. debarshiray commented on Mar 9, 2023

    @debarshiray
    Member

    I am closing this on the assumption that the emacsclient --tty problem is unrelated to the other two problems reported here.

    Please leave a comment or open an issue if you have reason to believe otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions