Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

chflags uappend allows truncate and overwrite

Hello!

I want to make a directory that should store backups. Other computers should connect to it by sharing.


To harden it a bit against encrypting trojans and other ransomware, I would like to set the permissions in this directory in a way that only creation of directories and new files or appending to existing files is permitted.


I cannnot see how to archive this with chmod +a ... , because append-only seems to be missing.


So I tried, since macos has not chattr, chflags:

sudo chflags -R sappend testdir

sudo chflags -R uappend testdir

(For user and system, just to be sure...)


But I can issue multiple times

echo testdir/TestFile.txt

echo testdir/TestFile.txt

without errors.

But append-only should reject attempts to alter existing information or truncate the file.


You can get rid of the flags with

sudo chflags -R nosappend testdir

sudo chflags -R nouappend testdir


Where am I wrong?


Thanks for help!


Andi

MacBook Pro with Retina display, OS X El Capitan (10.11.3), (MBP late 2013 model)

Posted on Apr 1, 2016 4:29 AM

Reply
5 replies

Apr 7, 2016 3:44 PM in response to anha

Are you talking about something like the $HOME/Public/Drop Box folder?

/bin/ls -ldeO@ "$HOME/Public/Drop Box"

drwx-wx-wx+ 3 me staff - 102 Jan 9 2010 /Users/raharris/Public/Drop Box

0: user:raharris allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,re adextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_i nherit

Than again, I could have misunderstood you real needs.

Apr 7, 2016 4:35 PM in response to anha

Hello anha,

Sorry, but that isn't going to work unless you have very specialized software doing the backups. Generally, Apple software is never going to open an existing file for writing or appending. Apple always creates new files and swaps out the old file for the new one. The only time Apple software wouldn't do that procedure is when it is doing something even more convoluted.

Apr 7, 2016 5:35 PM in response to BobHarris

Hello BobHarris,

no, you're on the right track.


chflags was my second approach to some append-only Dir with inherit.


I played with acl +a, but to no avail. I show you what I tried.


First the motivation:

I want a backup program on a win7/8 machine to be able to do resume after interruption of the write process, in write-append-mode. lbackup should be tamable for this...

And of course after doing the writing of the backup, a program should be able to do a verify.

If some encrypting trojan or the person typing (me) wants to overwrite or delete, this should fail as long as the rights for "Append Only Dir" are in place.


When I follow the idea of the right "append" to be inherited to a file freshly created:

mkdir TestDir; chmod ugo-w TestDir; chmod +a "$USER allow append" TestDir


(It doesn't show the right behavior. I'm not allowed to write. chmod u+w TestDir is no better, I can overwrite then.

append is there in the rights, but without "write" it doesn't allow to create the files, and with write I can overwrite them.

So I seem to want to sit on the missing hair line in between..)


I searched a lot and found some discussion answered by Gerrit DeWitt hinting that just that is possible with acl, but could not reproduce appnd: I can overwrite, and shan't.


This is NOT for the Mac itself, it takes care of protecting its backups quite ok, I feel, using time machine.

I want the mac to be a NAS in Append-Only for my windows clients 😉


Right now I'm a bit frustrated since others seem to have had append-only, but I can not reproduce the behavior.

(Ethan Benson even calls it undesireable that append-only should be inherited.)

Gerrit de Witt gives detailed examples of how to set up append-only-dir here. Adapted spelling of some rights, OK, but didn't work.

He even has a nice how-to for acl's (the linked version 1 is deleted, see here version 2


(My one liner with gerrit de Witts rights list...

(Explanation of the high-risk sudo rm -rf: I remove old tests in a sub-dir "3t" to be on the "fresh starting" side.):


mkdir ~/2t; cd ~/2t/; sudo rm -rf 3t; mkdir 3t; sudo chown root:admin 3t; sudo chmod 755 3t; sudo chmod +a "$USER allow readattr,readextattr,readsecurity,read,execute,list,search,writeattr,writeextat tr,add_subdirectory,add_file,append,file_inherit,directory_inherit" 3t; sudo chmod +a "$USER deny delete,delete_child" 3t; cd 3t; echo FirstWrite > 1test.txt; echo "Trying to OVERWRITE"; echo OverWrite > 1test.txt; echo "No ERROR on Overwrite above?? So no append-only"; echo Append-A-Line >> 1test.txt; ls -laeO; cat 1test.txt;



To etresoft: I do not want to use it locally. Just want to set up a share that has very limited rights.

Still any trojan on the machine of my family members will just have enough rights to delete backups pushed there. Pull backup is not widely spread, what a pity in these days. Again lbackup is cause for hope 😉

( I would prefer backup software companies taking this job serious, but neither acronis nor synology nor qnap did care to understand the need for this. My router manufacturer did listen. avm.de .)


I'm also searching for other OS / filesystem - combinations that would be a trustworthy backup tomb, but wanted to start on my mac.

It seems I have to dig into informatics in universities, programming L4 and filesystems, see here:trustworthy filesystem for L4.

Originally I hoped every OS with full ACL enabled could do, e.g Linux and ext4 or reiserfs, so every DSL router with telnet access, or raspi, or other small computer-like hardware that has USB for some HDD could be hardened, especially, by write-append.


Thanks!


Andi

chflags uappend allows truncate and overwrite

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.