Subject: Re: bug#27269: Sed --in-place is messing NTFS file permissions

From: Assaf Gordon <[email-masked]>
Date: Wed, 15 Nov 2017 02:23:31 -0700

Hello,

On 2017-06-06 08:45 PM, Maiko Cezar Rodrigues Costa wrote:
> Hi, I've a problem with sed when using the --in-place option in a mounted
> NTFS partition;

Thank you for the report.

I can reproduce this and I believe it is a regression in sed-4.4 that 
happens when an ntfs partition is mounted with "-o permissions".

To reproduce:

Create dummy NTFS partition and mount it:

   cd /tmp/
   dd if=/dev/zero of=ntfs.partition.bin bs=1M count=20
   mkfs.ntfs --force ./ntfs.partition.bin
   mkdir /tmp/mnt
   sudo mount -t ntfs -o permissions ./ntfs.partition.bin /tmp/mnt/
   cd /tmp/mnt

Create first file:

   $ echo hello > world
   $ ls -l
   total 1
   -rw-rw-r-- 1 gordon gordon 6 Nov 15 02:16 world

Use sed-4.2, permissions retained:

   $ sed-4.2.2 -i.bak-sed4.2 's/e/x/' world
   $ ls -l
   total 1
   -rw-rw-r-- 1 gordon gordon 6 Nov 15 02:16 world
   -rw-rw-r-- 1 gordon gordon 6 Nov 15 02:16 world.bak-sed4.2

Same with sed-4.4, permissions lost:

   $ sed-4.4 -i.bak-sed4.4 's/e/x/' world
   $ ls -l
   total 2
   ---------- 1 gordon gordon 6 Nov 15 02:16 world
   -rw-rw-r-- 1 gordon gordon 6 Nov 15 02:16 world.bak-sed4.2
   -rw-rw-r-- 1 gordon gordon 6 Nov 15 02:16 world.bak-sed4.4

I will investigate further to try and pinpoint the offending code.

regards,
  - assaf