10

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

4
  • I see nothing here that is out of the ordinairy. Have "coolsite" created as "700" (no permissions for group and others) and only the own user + admin can do something to it. All others get a permission denied.
    – Rinzwind
    Dec 29, 2017 at 14:06
  • So manually instruct users to remember to chmod 700 after touch ? Dec 29, 2017 at 14:09
  • 1
    joshsverns I think you can enforce that? (with umask). Oh good one @perlduck
    – Rinzwind
    Dec 29, 2017 at 14:10
  • Why couldn't you program it in ruby?
    – pipe
    Dec 30, 2017 at 18:34

1 Answer 1

31

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:

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .