From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Logging-in using ssh elevates the user privilege.
Date: Fri, 08 Mar 2019 14:46:00 -0000 [thread overview]
Message-ID: <20190308234638.0ada919bc31803cf064ca720@nifty.ne.jp> (raw)
In-Reply-To: <20190308141118.GM3785@calimero.vinschen.de>
[-- Attachment #1: Type: text/plain, Size: 694 bytes --]
Hi Corinna,
Thanks for your advice.
On Fri, 8 Mar 2019 15:11:18 +0100 Corinna Vinschen wrote:
> > In Linux, connect() in the client returns befor the
> > server calls accept(). However, in cygwin, connect()
> > does not return until the server calls accept().
>
> This is a result of the handshake to exchange credentials for
> getpeereid(). To workaround this issue, try building screen
> with a tweak. Server and as client should call
>
> setsockopt (sock, SOL_SOCKET, SO_PEERCRED, NULL, 0);
>
> before calling accept or connect.
Following your advice, I tried the patch attached and
confirmed the problem regarding -Q option is solved.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
[-- Attachment #2: screen-peercred.patch --]
[-- Type: application/octet-stream, Size: 1467 bytes --]
--- origsrc/screen-4.6.2/socket.c 2017-10-23 20:32:41.000000000 +0900
+++ src/screen-4.6.2/socket.c 2019-03-08 23:31:11.373592400 +0900
@@ -537,6 +537,9 @@
xseteuid(real_uid);
xsetegid(real_gid);
# endif
+#ifdef __CYGWIN__
+ setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
if (connect(s, (struct sockaddr *) &a, strlen(SockPath) + 2) != -1)
{
debug("oooooh! socket already is alive!\n");
@@ -628,6 +631,9 @@
return -1;
}
#endif
+#ifdef __CYGWIN__
+ setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
if (connect(s, (struct sockaddr *)&a, strlen(SockPath) + 2) == -1)
{
if (err)
@@ -1058,6 +1064,9 @@
{
len = sizeof(a);
debug("Ha, there was someone knocking on my socket??\n");
+#ifdef __CYGWIN__
+ setsockopt(ns, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
if ((ns = accept(ns, (struct sockaddr *)&a, (void *)&len)) < 0)
{
Msg(errno, "accept");
@@ -1308,6 +1317,9 @@
}
else
{
+#ifdef __CYGWIN__
+ setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
len = sizeof(a);
s = accept(s, (struct sockaddr *)&a, (void *)&len);
if (s < 0)
@@ -1343,6 +1355,9 @@
if (stat(sap->sun_path, &st))
return -1;
chmod(sap->sun_path, 0);
+#ifdef __CYGWIN__
+ setsockopt(s, SOL_SOCKET, SO_PEERCRED, NULL, 0);
+#endif
x = connect(s, (struct sockaddr *) sap, len);
chmod(sap->sun_path, st.st_mode);
return x;
[-- Attachment #3: Type: text/plain, Size: 219 bytes --]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2019-03-08 14:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 16:00 Takashi Yano
2019-03-06 16:15 ` Corinna Vinschen
2019-03-06 16:17 ` Corinna Vinschen
2019-03-07 10:08 ` Takashi Yano
2019-03-06 18:33 ` Achim Gratz
2019-03-07 11:23 ` Takashi Yano
2019-03-07 11:20 ` Andrey Repin
2019-03-07 15:35 ` Andrey Repin
2019-03-08 14:01 ` Takashi Yano
2019-03-08 14:11 ` Corinna Vinschen
2019-03-08 14:46 ` Takashi Yano [this message]
2019-03-08 14:52 ` Corinna Vinschen
2019-03-08 17:57 ` Andrew Schulman
2019-03-08 22:36 ` Takashi Yano
2019-03-08 23:19 ` Andrew Schulman
2019-03-09 1:49 ` Takashi Yano
2019-03-09 7:47 ` Michael Wild
2019-03-08 15:39 ` Takashi Yano
2019-03-08 15:56 ` Corinna Vinschen
2019-03-08 16:21 ` Takashi Yano
2019-03-08 17:14 ` Corinna Vinschen
2019-03-07 11:14 Takashi Yano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190308234638.0ada919bc31803cf064ca720@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).