[Bug 281751] Unable to start jail from vty1... virtual terminal

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 30 Sep 2024 11:49:56 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281751

--- Comment #36 from Alex Tutubalin <lexa@libraw.com> ---
(In reply to Olivier Certner from comment #35)

1) fstat -p on ttyv0 (/usr/sbin/jail -c succeeds):

USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
root     sh          6384 text /          2188 -r-xr-xr-x  168344  r
root     sh          6384 ctty /dev         74 crw-------   ttyv0 rw
root     sh          6384   wd /             5 drwxr-xr-x      23  r
root     sh          6384 root /            34 drwxr-xr-x      27  r
root     sh          6384    0 /dev         74 crw-------   ttyv0 rw
root     sh          6384    1 /dev         74 crw-------   ttyv0 rw
root     sh          6384    2 /dev         74 crw-------   ttyv0 rw
root     sh          6384   10 /dev         74 crw-------   ttyv0 rw

2) fstat -p on ttyv1 (jail -c fails):
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
root     sh          6812 text /          2188 -r-xr-xr-x  168344  r
root     sh          6812 ctty /dev         75 crw-------   ttyv1 rw
root     sh          6812   wd /             5 drwxr-xr-x      24  r
root     sh          6812 root /            34 drwxr-xr-x      27  r
root     sh          6812    0 /dev         75 crw-------   ttyv1 rw
root     sh          6812    1 /dev         75 crw-------   ttyv1 rw
root     sh          6812    2 /dev         75 crw-------   ttyv1 rw
root     sh          6812    5 /         69283 drwx------       4  r
root     sh          6812   10 /dev         75 crw-------   ttyv1 rw

It differs only by inode 69283 so
find / -inum 69283
results in
/var/run/xdg/root (this is folder with xdg_session.* file)

3) dtrace script you propose:
  - shows nothing if jail -c on ttyv0
  - outputs this if jail -c is started on ttyv1:

CPU     ID                    FUNCTION:NAME
  7  51518          pwd_chroot_chdir:return 
              kernel`do_jail_attach+0x20b
              kernel`amd64_syscall+0x158
              kernel`0xffffffff8104e7bb

Things are more clear now:
/var/run/xdg/username is created by pam_xdg, on 1st user login on ttyvN but not
on pts/N

So, ttyv0 is not magical:
  - logged out from all virtual consoles (ttyvN)
  - /var/run/xdg/root disappears 
  - logged in on ttyv1 - folder re-created.
  - Now I can start jail from ttyv1 but not from ttyv0 or ttyv2

Still do not know what pam_xdg is :)

-- 
You are receiving this mail because:
You are the assignee for the bug.