Re: screen-4.6.0 regression: within su: Cannot open your terminal '/dev/pts/14' - please check

Amadeusz Sławiński <[email protected]>
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>
On Fri, 30 Jun 2017 15:25:05 +0800
Clark Wang <[email protected]> wrote:

> On Thu, Jun 29, 2017 at 7:31 PM, Andrew Savchenko <[email protected]>
> wrote:
> 
> > Hi,
> >
> > I often use screen within su - username sessions, so that active
> > terminal (e.g. xterm) is owned by a user different from one using
> > su, e.g.:
> >
> > su - test
> > screen
> >
> > This worked fine before 4.6.0 (up to 4.5.1), with 4.6.0 I have:
> >
> > $ su - test
> > $ screen
> > Cannot open your terminal '/dev/pts/14' - please check.
> >
> > /dev/pts/14 is indeed not owned by user test, but this way screen
> > have worked fine for as long as I can remember, so this access
> > should not be mandatory.
> >
> > Any way to return the old behaviour?
> >  
> 
> The following patch (not a real fix) works fine for me. To me it
> looks like the ``#ifndef NAMEDPIPE'' part is wrongly removed from
> v4.5.x code.
> 
> --- src/screen.c        2017-06-30 15:03:24.886002321 +0800
> +++ ../screen-4.6.0/screen.c    2017-06-30 15:12:25.547628467 +0800
> @@ -1001,6 +1001,7 @@
>    attach_tty = "";
>    if (!detached && !lsflag && !cmdflag && !(dflag && !mflag
> && !rflag && !xflag) &&
>        !(sty && !SockMatch && !mflag && !rflag && !xflag)) {
> +      int fl;
> 
>      /* ttyname implies isatty */
>      SetTtyname(true, &st);
> @@ -1008,6 +1009,10 @@
>      tty_mode = (int)st.st_mode & 0777;
>  #endif
> 
> +    fl = fcntl(0, F_GETFL, 0);
> +    if (fl != -1 && (fl & (O_RDWR|O_RDONLY|O_WRONLY)) == O_RDWR)
> +      attach_fd = 0;
> +
>      if (attach_fd == -1) {
>        if ((n = secopen(attach_tty, O_RDWR | O_NONBLOCK, 0)) < 0)
>          Panic(0, "Cannot open your terminal '%s' - please check.",
> attach_tty);

Hey,

indeed that fixes it, thank you for investigating, I will release 4.6.1
soon.

Amadeusz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.