delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/06/20/16:09:54

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:from:to:references:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=acFRxe7UEEOUtTsy
ECdbmyQc3Co8DfTstGYYB2lAl9Ivv5Xtw+5F3uCBpfmzLsfIUk0HGGQRhtV1tkCL
KJH2mmJ9otGY77ZzVX5LGFH8Vo+nyxOgGVY7BtElVrnyjgXtcsH+jNazwbG6nsA6
2i/T66APEzW54a2owEzxAKoo83U=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:from:to:references:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=pZ/Jghawm59Ci5v3ESCwqk
Elh/8=; b=yAQesHVHrTVEELp1QnuHZwBgtS17Zh8P5r3+uR3tQDcg7LzXTFyrH+
sXdodSDaxUyOK2NRM7vqha4I/MO0OEV7fl3IokWHLyjHabKbLz0LiY1iwCTWeog4
ZEA7sGKcCpjaxdDa06lPUyR76K+7TF9Q5wJCdOTuDe8tl/iLQeZbw=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=sth, world
X-HELO: scc-mailout-kit-02.scc.kit.edu
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kit.edu; s=20190212; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:References:To:From:Subject; bh=eHM48dWfHEfi7/iTHmuVLTa1mtZB3KS1RX3wokqlVxs=; b=IIGfckFpJ/H56suWnRFpfRH7Jt+JmGS4h1wdtmQ8KAOlI5zpKiINH0cUd7UaB4Da88RbJZdyHm9yOojYAp23K1HtJD1D8m6IMgBW26esnOK0fAmMoXU6ZbXy9PP/oXXrAOpJ93dnB+B8N7VRFWMGqod1+cgDhSRwmCKCtWTEXbc=;
Subject: Re: Are there any changes to the access control to /proc/<PID>/fd/1 in cygwin 3?
From: "Till Riedel [TM]" <till DOT riedel AT kit DOT edu>
To: cygwin AT cygwin DOT com
References: <a0527553-ef09-60dd-5019-7278c5f12835 AT teco DOT edu> <ce76246c-bf9e-9988-97f7-93e7e206d764 AT SystematicSw DOT ab DOT ca> <b2eb4a82-c60e-de15-93d6-1840ce804afa AT kit DOT edu>
Message-ID: <53dbd37b-1725-b3a2-3976-c595a694be91@kit.edu>
Date: Thu, 20 Jun 2019 22:08:56 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0
MIME-Version: 1.0
In-Reply-To: <b2eb4a82-c60e-de15-93d6-1840ce804afa@kit.edu>

Hi Brian,

you actually hinted me at sth. : powershell.exe Start-Process bash  
\"-c\",\"\'echo hello world  \>`readlink /proc/$$/fd/1`\;sleep 10\'\" 
works as well.

I verified this:

 >echo hello >/proc/3235/fd/0
-bash: echo: write error: Bad file descriptor

 >echo hello >`readlink /proc/3235/fd/0`
works!?

Am I missing sth about symlinks?

BR

Till

Till Riedel [TM] @ 20.06.2019 (21:49) :
> Hi Brian,
>
> thanks for the reply.
>
> But proc/$$/fd/1 references the callers  stdout and not the callees as 
> /dev/stdout or /proc/self/fd/2 if called from eg. from bash, because 
> it is expanded before the call.
>
> What I was able to do is to inject messages into the callers stdout 
> and read from the callers stdin, which is when executing under 
> elevated priviledges (the behaviour you would want for a sudo).
>
> As said echo >/proc/$$/fd/1 hello world is not the problem and works 
> fine as you said as well. (I probably should not have said strangely 
> in the first place, because it is a whole different deal...)
>
> BR
>
> Till
>
>
>
> Brian Inglis @ 16.06.2019 (17:42) :
>> On 2019-06-15 12:27, Till Riedel wrote:
>>> I have been using a very handy sudo hack, that broke lately (I 
>>> think) when
>>> updating cygwin: https://github.com/imachug/win-sudo
>>> The trick is to spawn an elevated process using powershell and hook 
>>> up the
>>> calling file descripters. I now get "write error: Bad file descriptor"
>>> To reproduce call:
>>> powershell.exe Start-Process bash  \"-c\",\"\'echo \>\>/proc/$$/fd/1 
>>> hello
>>> world\;sleep 10\'\"
>>> IMHO this used to work in former versions (print out hello world on 
>>> the calling
>>> shell). Strangely
>>> bash -c "echo >/proc/$$/fd/1 hello world"
>>> works. So my initial guess is that is has to do with the decoupling 
>>> of Cygwin
>>> PIDs from Windows PIDs, but there were also changes in the proc file 
>>> system...
>>> Thanks a lot in advance for any help/thoughts!
>> Given:
>> $ bash -c 'ls -dglo /dev/std* /proc/self /proc/$$ /proc/self/fd/[012]'
>> lrwxrwxrwx 1 15 May 14  2013 /dev/stderr -> /proc/self/fd/2
>> lrwxrwxrwx 1 15 May 14  2013 /dev/stdin -> /proc/self/fd/0
>> lrwxrwxrwx 1 15 May 14  2013 /dev/stdout -> /proc/self/fd/1
>> dr-xr-xr-x 3  0 Jun 16 01:37 /proc/23846
>> lrwxrwxrwx 1  0 Jun 16 01:37 /proc/self -> 23846
>> lrwxrwxrwx 1  0 Jun 16 01:37 /proc/self/fd/0 -> /dev/pty0
>> lrwxrwxrwx 1  0 Jun 16 01:37 /proc/self/fd/1 -> /dev/pty0
>> lrwxrwxrwx 1  0 Jun 16 01:37 /proc/self/fd/2 -> /dev/pty0
>>
>> the following seems to work as expected:
>> $ powershell Start-Process bash  \"-c\",\"\'echo \>\>/dev/stdout hello
>> world\;sleep 10\'\"
>>
-- 
KIT- Research University in the Helmholtz Association

Dr.-Ing. Till Riedel
Lab Leader TECO, SDSC-BW/SDIL (AR)

Karlsruhe Institute of Technology (KIT)
Institute of Telematics (TM)
Pervasive Computing Systems - Prof. Beigl


Bldg. 07.07., Room 211
Vincenz Prießnitz Str. 1, 76131 Karlsruhe

+49 (0)721 608 41706
www.teco.kit.edu/~riedel


--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019