On Tue, 8 Apr 2025 00:12:00 +0900
Takashi Yano wrote:
> > 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.

Authentication revised. Please try.

-- 
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-cygwin-auth.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_EXCLUDES="install-sh"
--- origsrc/screen-5.0.0/socket.c       2025-04-08 00:24:31.851467200 +0900
+++ src/screen-5.0.0/socket.c   2025-04-08 16:31:46.927444900 +0900
@@ -82,6 +82,17 @@
 #include "tty.h"
 #include "utmp.h"
 
+#ifdef __CYGWIN__
+typedef void *HANDLE;
+typedef void *HMODULE;
+typedef uint32_t DWORD;
+typedef uintptr_t DWORD_PTR;
+#define INVALID_HANDLE_VALUE ((HANDLE)-1)
+#define WINVER 5
+#define MAX_PATH 260
+#include <sys/cygwin.h>
+#endif
+
 static int CheckPid(pid_t);
 static void ExecCreate(Message *);
 static void DoCommandMsg(Message *);
@@ -1214,6 +1225,7 @@ static bool CheckPassword(const char *pa
 #else /* ENABLE_PAM */
 
 static bool CheckPassword(const char *password) {
+#ifndef __CYGWIN__
        bool ret = false;
        char *passwd = 0;
 
@@ -1256,6 +1264,16 @@ static bool CheckPassword(const char *pa
        ret = (strcmp(passwd, p->sp_pwdp) == 0);
 #endif
        return ret;
+#else
+       struct passwd *p;
+       p = getpwnam(ppp->pw_name);
+       if (p == NULL)
+               return false;
+
+       HANDLE hToken = (HANDLE) cygwin_logon_user (p, password);
+       cygwin_set_impersonation_token (hToken);
+       return (hToken == INVALID_HANDLE_VALUE);
+#endif
 }
 #endif /* ENABLE_PAM */
 
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/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);

Reply via email to