[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Non-privileged user can only connect to /dev/pts/X once?!
From: |
Marcin Cieslak |
Subject: |
Re: Non-privileged user can only connect to /dev/pts/X once?! |
Date: |
Thu, 4 Jun 2020 10:05:41 +0000 |
On Wed, 3 Jun 2020, Joe Yeung wrote:
So I re-compiled with debug turned on which led me to this function where
the difference is made between the initial and the subsequent connection.
int secopen(char *name, int flags, int mode)
{
int fd;
xseteuid(real_uid);
xsetegid(real_gid);
fd = open(name, flags, mode);
xseteuid(eff_uid);
xsetegid(eff_gid);
return fd;
}
The very first time I connection, open() succeeded, but subsequent ones
always return -1.
What is the errno() value? Can you say more about the operating system you
are using?
My host is on FreeBSD 11.x and there I get pseudoterminals and screen 4.7.0.
I did a quick test with "serial=pty" setting on a Xen HVM guest
(which has I/O done with qemu) and noticed the following:
I have /dev/pts/3 available with the console after the machine boots
(available only to root). After the pseudoterminal closes, /dev/pts/3
disappers from the /dev/ tree and an attempt to open it results
in "Permission denied".
But in parallel /dev/pts/4 becomes available. Having that one closed,
/dev/pts/3 appears again.
One more interesting thing: I open screen with
screen /dev/pts/3 115200
to connect to the console of the guest, after this I open another
window to the same terminal with ctrl-A :screen /dev/pts/3 115200
The second window remains mute (no input and output), the
first one works. But when I close the first window with the kill
screen command, the second terminal becomes active and /dev/pts/3
does not disappear.
Pseudoterminals are allocated dynamically - maybe if qemu
re-opens the pseudoterminal master it simply gets another terminal
to use?
Marcin
smime.p7s
Description: S/MIME Cryptographic Signature