Disabling chmod for some users

1

In Linux system, assume that there is user 'A' (non-root user who has ssh login permission).

'A' owns an executable file "A.out".

I want to allow 'A' to read/execute "A.out"

However, I don't want 'A' to change permission of "A.out"

as a root user, how can I enforce this?(in Ubuntu server)

thank you in advance.

daehee

Posted 2014-06-11T07:05:43.087

Reputation: 405

Answers

3

The only two ways you can enforce this are:

  1. Change the file's owner to root or another user.

  2. Use SELinux/AppArmor/SMACK to deny the chmod usage.

user1686

Posted 2014-06-11T07:05:43.087

Reputation: 283 655

I'm not really sure, but isn't it an option to set the file as immutable? (I.e. chattr +i A.out). Only superusers can do this and the file will be read-only. The user would still be able to set write permissions but cannot write to the file. – Steen Schütt – 2017-08-22T12:43:03.143

Just to add, when/if you do change file's owner to root, make sure that "userA" has read-only access to file by being in group-owner group of file. – phoops – 2014-06-11T07:10:22.510

@edvinas.me: Or by being in the file's ACL. – user1686 – 2014-06-11T07:12:35.833

it seems that if the owner of 'A.out' is root and group of 'A.out' is 'A' and if I give the permission of 'A.out' ---r-x---, it works as I want. A can RX the file 'A.out' but cannot change the permission. Am i right? – daehee – 2014-06-11T07:19:13.830