I want to ensure that users of my system are incapable of chmodding files +x, and I do not want anything in /home/ or /var/ to be executable.
I can't put them on separate partitions.
Running Ubuntu 9.04 Server.
|
I want to ensure that users of my system are incapable of chmodding files +x, and I do not want anything in /home/ or /var/ to be executable. I can't put them on separate partitions. Running Ubuntu 9.04 Server.
| |||||||||
feedback
|
|
I was going to suggest a wrapper to chmod or something, but the more I think about it, the users will eventually find a way around this (scp an executable from another box, or run perl -s "chmod('FILE');", etc... So, I think the FS method is the best. Since you say you can't move them to a new file system, what about using a --bind mount to "remount" /home and /var without exec privileges?
I'm not sure if that would work or not, but seems promising... EDIT:
Oh well... --bind is still a fun option... | |||||||||
feedback
|
|
I can think of 2 ways of doing this, one dirty, and one good. Let's start with the dirty. Write a shell script that runs very regularly as a cronjob, say every 5 or 10 minutes. It would explicitly remove the exec flag from all files in those two directories, i.e.
The better way is to do it at the filesystem level. Create new partitions to house both var and home, this is considered best practice anyway. Then add the ‘noexec’ option to mount. This will prevent, at the filesystem level, the execution of files stored within those directories. | |||
|
feedback
|
|
This is a perfect example of the kind of question that should be answered thusly: You seem to have come up with a solution for a complex problem, and are now asking specific questions on how to implement this solution. Could you please instead describe the original problem you are trying to solve? My experience is that it's pretty important for a sysadmin to know when to respond to a request with "what? why?". How important depends on the propensity of the users to describe their original problem or to attempt to come up with their own solutions and ask for assistance in implementing them. In certain environments, it's the difference between expensive catastrophically bad solutions, and cheap good solutions. | |||
|
feedback
|
|
don't forget to make sure /tmp /var/tmp and other user-writable dirs also are on the partitions mount with noexec flag. | |||
|
feedback
|
|
Guess you can also use inotifywait with -r, -m and -e attrib options to reset -x flag if it is set by users | |||
|
feedback
|
|
Sounds like you have a policy problem... many scripts can be run by simply invoking the interpreter directly: So presumably you are trying to prevent a native executable from running? Best to deal with this problem via policy and policing/auditing... | |||
feedback
|