screen-users
[Top][All Lists]
Advanced

[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: Joe Yeung
Subject: Re: Non-privileged user can only connect to /dev/pts/X once?!
Date: Thu, 4 Jun 2020 22:12:35 -0700

Thanks for your response.
I am a bit busy today and wasn’t able collect the errno from the failed open() 
call.

My system is running Yocto with screen 4.8 but this issue is also observable on 
Ubuntu.

In your case where the pts jumps from 3 to 4, how did you find out it had gone 
to 4 in the first place? 
One of my challenges is to find out what pts qemu uses when I spun up the VM. 
Fortunately it is displayed on the command line. If it is to jump around like 
your set up, that would be painful because at any instance of time, you 
wouldn’t know which pts to use.

Regards,
Joe.





> On Jun 4, 2020, at 03:05, Marcin Cieslak <saper@saper.info> wrote:
> 
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]