Re: sudo

Lorens Kockum <[email protected]> Sat, 4 Apr 2015 23:34:33 +0200
Newsgroups gmane.comp.capabilities.general
Message-ID <[email protected]>
On Sat, Apr 04, 2015 at 03:12:55PM -0500, Dan Connolly wrote:
> Here's a puzzle: Bob wants to share one of his directories with Alice
> so both of them can write to it but nobody else can.
> The only solution(s) I can see involve root access, not to mention the
> global namespace of group names:

Just for the sake of discussion, if you're not root and you have
work to do:

# setup
mkdir -p ~/public/shared
chmod go=x ~/ ~/public ~/public/shared/
mkdir -p ~/private
chmod go= ~/private

# Bob
PETNAME=alice
KEY=`openssl hash -hex ${KEYLEN:-64}` # slight bashism
REALDIR=~/public/shared/$PETNAME-$KEY
mkdir $REALDIR
chmod ugo=rwx $REALDIR
ln -s $REALDIR ~/private/$PETNAME
cd $PETNAME
echo realdir is $REALDIR | mail -s shared_dir alice@play

# Alice
PETNAME=bob
mkdir -p ~/private
chmod go= ~/private
ln -s $REALDIR ~/private/$PETNAME

To make certain nobody can change your files even if they obtain
the key you could also chmod go=rx $REALDIR and have one
one-way communication directory each.

Not perfect as such, since there are usually ways for an
unprivileged process to see the information of another user's
processes (ps, other things in /proc), but I believe that if
root agrees then one should be able to block those. Anyway,
using it for just quick copies (or even hardlinks) of files
using petnames was (20 years ago) more than sufficient to keep
my collaborative student projects away from envious eyes :)