On Mon, 07 Apr 2025 10:38:52 -0400
Andrew Schulman wrote:
> > On Sat, 05 Apr 2025 07:02:08 -0400
> > Andrew Schulman wrote:
> > > screen 5.0.0 now includes calls to TIOCCONS, like this:
> > > 
> > > ioctl(consredirfd[1], TIOCCONS, (char *)&on)
> > > 
> > > Since TIOCCONS seems not to be present in Cygwin, can someone please 
> > > suggest
> > > what the equivalent would be?
> > 
> > There is not default console on cygwin such as /dev/tty0 or /dev/console
> > on Linux. cygwin has /dev/console but it is an alias of current console
> > device such as /dev/cons0.
> > 
> > So we cannot implement TIOCCONS in cygwin.
> > 
> > What about commenting out the body of TtyGrabConsole() like:
> ...
> > Does something behaves wrong with that?
> 
> Thanks. That's a good idea. Unfortunately when I try it screen hangs,
> unresponsive. Same result if I just comment out the call to ioctl().
> 
> That might be because of the missing ioctl(), or it might be because of some
> other change since screen 4.9.1. Not sure. So I think my next stop is to ask
> the screen developers. 

Hmm, in my environment, attached seem to work for me.

-- 
Takashi Yano <takashi.y...@nifty.ne.jp>
#
# cygport build script for screen
#

NAME=screen
VERSION=5.0.0
RELEASE=1

# Packaging

CATEGORY="Utils"
SUMMARY="Run separate screens on a single terminal"
DESCRIPTION="Screen is a full-screen window manager that multiplexes a physical 
terminal between several processes, typically interactive shells. You can 
switch between windows, create new windows with other programs in them, kill 
the current window, view a list of the active windows, turn output logging on 
and off, copy text between windows, and view scrollback history. Programs 
continue to run when the screen session is detached from the terminal, so you 
can log in again later and continue working."
HOMEPAGE="https://www.gnu.org/software/screen/";
LICENSE=GPL-3.0-only

# Sources

#GIT_URI='git://git.savannah.gnu.org/screen.git'
#inherit git
#SRC_DIR=screen/src
SRC_URI="http://ftp.gnu.org/gnu/screen/screen-${VERSION}.tar.gz";

PATCH_URI="
        screen-etcscreenrc.patch
        screen-peercred.patch
        screen-no-TIOCCONS.patch
"
#       screen-install-exe.patch

CYGPORT_USE_UNSTABLE_API=1
src_unpack_hook ()
{
        inform "Copying in CYGWIN-PATCHES"
        cp -av ${top}/CYGWIN-PATCHES "${S/\/src\///origsrc/}"
}

# Build

BUILD_REQUIRES="
  libcrypt-devel
  libncurses-devel
"

CYGCONF_ARGS="--with-sys-screenrc=/etc/screenrc --enable-colors256 
--disable-pam"

src_compile() {
  cd ${S}
  cygautoreconf
  lndirs
  cd ${B}
  cygconf
  cygmake
}

src_install()
{
        dodir /usr/share/doc/${PN}
        dodir /usr/share/doc/Cygwin

        cd "$B"
        cyginstall

        insinto /etc
        newins "$S"/etc/etcscreenrc screenrc
        make_etc_defaults /etc/screenrc

        exeinto /usr/share/screen
        doexe "$S"/CYGWIN-PATCHES/test/256colors.pl

        dosym ../Cygwin/${PN}.README /usr/share/doc/${PN}/README.Cygwin
}
diff -ur screen-4.0.3.orig/etc/etcscreenrc screen-4.0.3/etc/etcscreenrc
--- screen-4.0.3.orig/etc/etcscreenrc   2003-12-05 08:46:13.000000000 -0500
+++ screen-4.0.3/etc/etcscreenrc        2007-07-06 16:17:38.140625000 -0400
@@ -9,6 +9,7 @@
 #startup_message off
 
 #defflow on # will force screen to process ^S/^Q
+defflow off    # leave this off, so we can save in *emacs
 
 deflogin on
 #autodetach off
@@ -65,6 +66,9 @@
 termcap xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
 terminfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
 
+# Set the hardstatus prop on gui terms to set the titlebar/icon title
+termcapinfo xterm*|rxvt*|kterm*|Eterm*|cygwin hs:ts=\E]0;:fs=\007:ds=\E]0;\007
+
 #
 # Do not use xterms alternate window buffer. 
 # This one would not add lines to the scrollback buffer.
--- origsrc/screen-5.0.0/socket.c       2024-08-29 04:55:03.000000000 +0900
+++ src/screen-5.0.0/socket.c   2025-04-06 01:06:10.859252400 +0900
@@ -1221,7 +1230,11 @@ static bool CheckPassword(const char *pa
                Panic(0, "\r\ncan't get root uid/gid\r\n");
 
 #ifndef _PWD_H
+#ifdef __CYGWIN__
+       p = getpwnam(ppp->pw_name);
+#else
        p = getpwnam_shadow(ppp->pw_name);
+#endif
 #else
        p = getspnam(ppp->pw_name);
 #endif
--- origsrc/screen-5.0.0/tty.c  2024-08-29 04:55:03.000000000 +0900
+++ src/screen-5.0.0/tty.c      2025-04-06 00:57:11.489640800 +0900
@@ -802,6 +802,7 @@ static void consredir_readev_fn(Event *
 
 int TtyGrabConsole(int fd, bool on, char *rc_name)
 {
+#ifndef __CYGWIN__
        Display *d;
 #ifdef SRIOCSREDIR
        int cfd;
@@ -880,6 +881,7 @@ int TtyGrabConsole(int fd, bool on, char
        consredir_ev.type = EV_READ;
        consredir_ev.handler = consredir_readev_fn;
        evenq(&consredir_ev);
+#endif
        return 0;
 }
 
--- origsrc/screen-5.0.0/socket.c       2024-08-29 04:55:03.000000000 +0900
+++ src/screen-5.0.0/socket.c   2025-04-06 01:06:10.859252400 +0900
@@ -361,6 +361,9 @@ int MakeServerSocket(void)
        a.sun_path[ARRAY_SIZE(a.sun_path) - 1] = 0;
        xseteuid(real_uid);
        xsetegid(real_gid);
+#ifdef __CYGWIN__
+    setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
        if (connect(s, (struct sockaddr *)&a, strlen(SocketPath) + 2) != -1) {
                if (quietflag) {
                        Kill(D_userpid, SIG_BYE);
@@ -390,6 +393,9 @@ int MakeServerSocket(void)
        chmod(SocketPath, SOCKMODE);
        if (chown(SocketPath, real_uid, real_gid))
                Panic(errno, "chown");
+#ifdef __CYGWIN__
+    setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
        if (listen(s, 5) == -1)
                Panic(errno, "listen");
 #ifdef F_SETOWN
@@ -412,6 +418,9 @@ int MakeClientSocket(int err)
        a.sun_path[ARRAY_SIZE(a.sun_path) - 1] = 0;
        xseteuid(real_uid);
        xsetegid(real_gid);
+#ifdef __CYGWIN__
+    setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
        if (connect(s, (struct sockaddr *)&a, strlen(SocketPath) + 2) == -1) {
                if (err)
                        Msg(errno, "%s: connect", SocketPath);
@@ -1221,7 +1230,11 @@ static bool CheckPassword(const char *pa
                Panic(0, "\r\ncan't get root uid/gid\r\n");
 
 #ifndef _PWD_H
+#ifdef __CYGWIN__
+       p = getpwnam(ppp->pw_name);
+#else
        p = getpwnam_shadow(ppp->pw_name);
+#endif
 #else
        p = getspnam(ppp->pw_name);
 #endif

Reply via email to