delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/01/22/03:50:17

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:date:message-id:from:reply-to:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=L72JF8
0f4l0C4CHOQaRlEbu6a011czPp8nnCrglxPJNmAVi6aHYv1zTEhoOVeae+aL5o8e
lBvowGN7SMpwge3YwRPuJYAsDcvik7pNzftCPlr5iLIqdgWK8Po2Pb+mdA2Lsr6z
1eiVeJt7VUTSLQ7/0rrzjiPAZBbpLq7Wtd7Bc=
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:date:message-id:from:reply-to:to:subject
:references:in-reply-to:content-type; s=default; bh=SKprUnAJMPF7
oaPnkABD3kpk35U=; b=b+9HvFAnhUC3xwA0frXZQcqCZItL6nwOzkXvKK/HMq8I
aII6Z67M6RvYNCf3zH+7FtxJRwK55UO7QNJoeDAYcDhxQ6HzjiYk+hTWvpeWReIP
BwGGQ2U7t0fNJ/QTNnB7bkVhgwzto4WkD1Q5v/TZzxW6RhQPBCC4409an9DZjSY=
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=-0.7 required=5.0 tests=BAYES_20,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=birth, Birth, D*@, ls
X-HELO: lb3-smtp-cloud8.xs4all.net
Date: Tue, 22 Jan 2019 09:50:00 +0100
Message-ID: <d6431739e2801a80d73e7cb68b4fcc19@smtp-cloud8.xs4all.net>
From: Houder <houder AT xs4all DOT nl>
Reply-To: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux
References: <0f030e809f063f5a5e64ff7a7a0c3227 AT xs4all DOT nl> <20190106201950 DOT GC4430 AT calimero DOT vinschen DOT de>
In-Reply-to: <20190106201950.GC4430@calimero.vinschen.de>
User-Agent: mua.awk 0.99
X-IsSubscribed: yes

On Sun, 6 Jan 2019 21:19:50, Corinna Vinschen  wrote:
> 
> On Dec 16 17:31, Houder wrote:
> > L.S.,
> >
> > /dev/fd/N not synonymous with file descriptor N; it is on Linux
> >
> > 64-@@ cat /dev/fd/0 <<\EOF
> > > Hi
> > > EOF
> > cat: /dev/fd/0: No such file or directory
> >
> > fails on Cygwin; not on Linux.
> >
> > Also see:
> >
> >     https://cygwin.com/ml/cygwin/2018-12/msg00028.html
> >     ( Bash heredoc on FD 3 )
> >
> > Based on the output of strace on Linux, I composed an STC, that duplicates
> > the steps taken by bash (and cat).
> 
> This should work in the latest developer snapshot uploaded to
> https://cygwin.com/snapshots/  Please give it a try.
> 
> Thanks,
> Corinna

Nice!

This solves: <program> -i /dev/fd/N N<<EOF (i.e. Steven Penny's problem)

Howver ...
(and I sure that I am not telling you anything new)

it still not the same as Linux ...

So, for the record only:

 - suppose a hacker deletes the logfile, but the file is still "help open"
   by some program
 - the logfile can be rescued on Linux, but not on Cygwin

64-@@ echo aap > aap.txt
64-@@ tail -f aap.txt
aap

.. in another terminal
64-@@ ls -l /proc/4120/fd # 4120 is the procid of "tail"
total 0
lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 0 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 1 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 2 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 3 -> /home/Henri/redirect/aap.txt

64-@@ stat -L /proc/4120/fd/3 # shows a file of 4 bytes ...
  File: /proc/4120/fd/3
  Size: 4               Blocks: 1          IO Block: 65536  regular file
Device: 33d91880h/869865600d    Inode: 35747322042382612  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   Henri)   Gid: (  513/    None)
Access: 2019-01-22 09:24:41.978178200 +0100
Modify: 2019-01-22 09:24:41.978178200 +0100
Change: 2019-01-22 09:24:41.978178200 +0100
 Birth: 2019-01-22 09:24:41.978178200 +0100

64-@@ rm aap.txt # hacker removing the logfile

64-@@ stat -L /proc/4120/fd/3
  File: /proc/4120/fd/3
  Size: 4               Blocks: 1          IO Block: 65536  regular file
Device: 33d91880h/869865600d    Inode: 35747322042382612  Links: 0
Access: (0644/-rw-r--r--)  Uid: ( 1000/   Henri)   Gid: (  513/    None)
Access: 2019-01-22 09:24:41.978178200 +0100
Modify: 2019-01-22 09:24:41.978178200 +0100
Change: 2019-01-22 09:26:25.021040800 +0100
 Birth: 2019-01-22 09:24:41.978178200 +0100

64-@@ cp /proc/4120/fd/3 noot.txt # logfile rescue
64-@@ cat noot.txt # empty! (however, this works on Linux)
64-@@ cat /proc/4120/fd/3 # indeed, does not show contents
64-@@

=====


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