On Thu, Jun 29, 2017 at 7:31 PM, Andrew Savchenko <birc...@gmail.com> 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);
_______________________________________________
screen-users mailing list
screen-users@gnu.org
https://lists.gnu.org/mailman/listinfo/screen-users

Reply via email to