From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36871 invoked by alias); 8 Mar 2019 14:01:47 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 36863 invoked by uid 89); 8 Mar 2019 14:01:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Repin, andrey, repin, Andrey X-HELO: conssluserg-06.nifty.com Received: from conssluserg-06.nifty.com (HELO conssluserg-06.nifty.com) (210.131.2.91) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Mar 2019 14:01:44 +0000 Received: from Express5800-S70 (ntsitm424054.sitm.nt.ngn.ppp.infoweb.ne.jp [219.97.74.54]) (authenticated) by conssluserg-06.nifty.com with ESMTP id x28E1WWH028408 for ; Fri, 8 Mar 2019 23:01:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com x28E1WWH028408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1552053694; bh=DX7oC1VOOBpRsANefAb8miz+eHh8jzqNTHd3mbVbCRY=; h=Date:From:To:Subject:In-Reply-To:References:From; b=YVXXt4tC1zEql0nb7PuQE0AQa69qXtg8ai8us2XRaCiBc8VWnPW15Sc3DJ+oApipQ g2UIPSmWISGL917c3QQLCsrlPZMRGc5rBIrx3/gKhay+1I5kDXobxkVcSMiFC9VD6C r8JbaksS6a3J3RWJnMYUgnXtMnGPuMAbif40yaAfWpvEOCuW2a6Zen5nKfAB9j7OOk FWwiM6WTgbXynsCfeLFWE5SR+kLeEbrOA5PCmPjrhARNo8Cow3tNv7e951sn4kWYtZ L9WJScmTOI3CLC/0cSyJ0o53WlXH9HBvp+ARLNIYICrwM0EHhmnNWuUZdjXmFIP6nh rtwKi8n4kYU2g== Date: Fri, 08 Mar 2019 14:01:00 -0000 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Logging-in using ssh elevates the user privilege. Message-Id: <20190308230138.b7f6b5ac90c9a14cde2647c1@nifty.ne.jp> In-Reply-To: <51233666.20190307182445@yandex.ru> References: <20190307010000.fc28b73739c2dd66e609982b@nifty.ne.jp> <381052629.20190307141955@yandex.ru> <51233666.20190307182445@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Fri__8_Mar_2019_23_01_38_+0900_rK2uvNdCkxncHjZu" X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00164.txt.bz2 --Multipart=_Fri__8_Mar_2019_23_01_38_+0900_rK2uvNdCkxncHjZu Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-length: 1359 Hello, Thank you for the information. On Thu, 7 Mar 2019 18:24:45 +0300 Andrey Repin wrote: > > GNU screen freeze without much of an effort under Cygwin. > > Try detaching from running screen and then running screen -ls. > > Past discussion > http://sourceware.org/ml/cygwin/2017-05/msg00448.html > mid:16810313565.20170527142723@yandex.ru I looked into this problem of GNU screen and found the cause is very different from that of the problem I had reported. The problem I had reported is due to the failure of sending signal, which is caused by mismatch of tokens between ssh session and mintty session. On the other hand, the problem you mentioned is due to the difference in the behaviour of socket API. In Linux, connect() in the client returns befor the server calls accept(). However, in cygwin, connect() does not return until the server calls accept(). Attached test code clarifies the difference. [Result in Linux] Server: Created. Server: Binded. Server: Listened. Client: Created. Client: Connected. Client: Written. Server: Accepted. 10: 1234567890 Server: Read. [Result in Cygwin] Server: Created. Server: Binded. Server: Listened. Client: Created. Server: Accepted. Client: Connected. Client: Written. 10: 1234567890 Server: Read. I am not sure why cygwin behaves differently from linux. -- Takashi Yano --Multipart=_Fri__8_Mar_2019_23_01_38_+0900_rK2uvNdCkxncHjZu Content-Type: text/x-csrc; name="sockunix.c" Content-Disposition: attachment; filename="sockunix.c" Content-Transfer-Encoding: 7bit Content-length: 1701 #include #include #include #include #include #include #include #include #include #include #define SOCKNAME "sock_unix_test" int main() { int fd; struct sockaddr_un sunx; pid_t pid; ssize_t len; char buf[BUFSIZ]; memset(&sunx, 0, sizeof(sunx)); sunx.sun_family = AF_UNIX; strncpy (sunx.sun_path, SOCKNAME, sizeof(sunx.sun_path) -1 ); pid = fork(); if (pid) { int fd1; fd = socket(AF_UNIX, SOCK_STREAM, 0); printf("Server: Created.\n"); if (fd < 0) { perror("socket"); goto end_server; } if (bind(fd, (struct sockaddr *)&sunx, sizeof(sunx)) < 0) { perror("bind"); goto end_server; } printf("Server: Binded.\n"); if (listen(fd, 1) < 0) { perror("listen"); goto end_server; } printf("Server: Listened.\n"); usleep(2000000); fd1 = accept(fd, 0, 0); if (fd1 < 0) { perror("accept"); goto end_server; } printf("Server: Accepted.\n"); while ((len = read(fd1, buf, sizeof(buf))) > 0) { buf[len] = '\0'; printf("%d: %s\n", len, buf); } printf("Server: Read.\n"); close(fd1); end_server: close(fd); kill(pid, SIGTERM); wait(NULL); if (unlink(SOCKNAME) < 0) { perror("unlink"); } } else { usleep(1000000); fd = socket(AF_UNIX, SOCK_STREAM, 0); printf("Client: Created.\n"); if (fd < 0) { perror("socket"); goto end_client; } if (connect(fd, (struct sockaddr *)&sunx, sizeof(sunx)) < 0) { perror("connect"); goto end_client; } printf("Client: Connected.\n"); write(fd, "1234567890", 10); printf("Client: Written.\n"); end_client: close(fd); } return 0; } --Multipart=_Fri__8_Mar_2019_23_01_38_+0900_rK2uvNdCkxncHjZu Content-Type: text/plain; charset=us-ascii Content-length: 219 -- 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 --Multipart=_Fri__8_Mar_2019_23_01_38_+0900_rK2uvNdCkxncHjZu--