Is it possible to implement a "name" booking system using linux file permissions

I have a linux multi user server with 100+ users in /etc/passwd

I would like to allow users to "book" / "reserve" a name of their liking (in this case a subdomain, but that details doesn't matter)

I have created a directory called /reservations and with chmod 777.

If user johndoe does, touch /reservations/coolsite, he indicates that he would like to "own" that name "coolsite"

The "mechanism" should be set up so that,

  • johndoe can have a change of mind later, and rm /reservations/coolsite to un-book that name

  • another user is not allowed to touch /reservations/coolsite, because johndoe asked for it first.

  • if johndoe rm his file, another user is allow to book it.

  • users can't rm / rename / mv / etc other folks files

  • user johndoe can have multiple bookings by doing touch /reservations/coolsite && touch /reservations/coolsite2

Is this possible using some kind of standard linux permissions mechanism?

I would hate to resort to perl for this, my perl skills have become rusty since the day ruby came along with her wavy blonde hair ...


What you ask for the directory /reservations is exactly how the standard /tmp directory behaves:

Every user can create files in there and only he is allowed to delete or modify them. This is achieved by the t bit (aka sticky bit) in the permissions. No user needs special permissions or umasks then.

Thus:

chown root /reservations
chmod 1777 /reservations

is all you need. The chown root is only to prevent other (regular) users from fiddling around with that directory. It's not really needed. Read more about the sticky bit here:

  • https://en.wikipedia.org/wiki/Sticky_bit
  • What is the "t" letter in the output of "ls -ld /tmp"?