Disable rm -rf * or rm -rf / in Cent OS


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Disable rm -rf * or rm -rf / in Cent OS
# 8  
Old 07-09-2013
In this case you could think about some workarounds:
You could rename the binary for rm so that only you know it's name, though all places (scripts, cronjobs, etc.) where it is being called will throw an error when they do not find it, for the time of development.
Though you will always have to keep that in mind so when an OS update is to be installed or something similar, you will have to give it it's old name.
Some OSes do have an alias to rm with the -i switch, so that every time it is being issued, you will get a prompt that you have to commit, if you want to delete something.
This User Gave Thanks to zaxxon For This Post:
# 9  
Old 07-09-2013
If the users have root access, you really can't stop them from doing anything.

Requiring everyone to have root access is a bad design. Do you have a bug tracking system? Enter a bug about how giving everyone root access allows everyone to literally destroy the system, even accidentally. Especially if you've already had problems with it happening.

One thing you can do that might help, though, is use the "chattr" utility to set the immutable flag on files you don't want changed or deleted:
Code:
chattr +i /some/file/name

This User Gave Thanks to achenle For This Post:
# 10  
Old 07-09-2013
In addition to what zaxxon said, you could rename the rm binary and create an alias instead that handles the command and sets custom limitations to it in a script pointing to the renamed binary.

edit: I think you don't even have to rename the binary when you create an alias with the same name. The users will still be able to run the binary of they specify the location though.

Last edited by Subbeh; 07-09-2013 at 12:01 PM..
This User Gave Thanks to Subbeh For This Post:
# 11  
Old 07-09-2013
Quote:
Originally Posted by shiek.kaleem
Hope that could have been in my hand .Its already been developed and now only thing i can do as an admin is to stop the users to stop them from executing the deadly commands
You are in a bad situation. You cannot prevent root from being root.

Why does your application need root? Cannot it be encapsulated somehow?

An alias can help, but that will only work interactively, and there are always ways around it.
This User Gave Thanks to Corona688 For This Post:
# 12  
Old 07-09-2013
For the end user level its been encapsulated but for the local development it has been set free to use root.

---------- Post updated at 11:21 PM ---------- Previous update was at 11:12 PM ----------

Guys In one of my screen share sessions with an end user, saw an linux environment where the rm command and usage of any type of special characters have been disabled totally .

@Zaxxon: Is it the same workaround that you mentioned in your comment .
Is it ok to move the binary from the location /etc/sbin to /etc/bin and apply ACL.

---------- Post updated at 11:29 PM ---------- Previous update was at 11:21 PM ----------

achenle : Does the chattr utility you mentioned can be applied to set flag for ownership on a directory and its working on ext3 filesystem. I have been googling it for a time and didnt get the correct answer for these things.Your answer will solve one more important issue for me. Smilie
# 13  
Old 07-09-2013
Quote:
Originally Posted by shiek.kaleem
Guys In one of my screen share sessions with an end user, saw an linux environment where the rm command and usage of any type of special characters have been disabled totally .
As long as you're OK with them re-enabling it, you can put this in root's ~/.profile or ~/.bashrc or whatever equivalent they use.

Code:
alias rm=false
set -f

But this will probably seriously inconvenience them, too.

Quote:
Is it ok to move the binary from the location /etc/sbin to /etc/bin and apply ACL.
Moving around essential binaries is not a good idea. If you break something, you may lose the ability to put it back.
This User Gave Thanks to Corona688 For This Post:
# 14  
Old 07-29-2013
Why not just move the rm command and redefine it as a script then you can issue "please verify your command". Of course you will want to be careful, since now rm expects input in the case you're trying to exercise care. Anything that is scripted should run the old version of rm.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Add persistent route in cent os 6.5

Hi , I have cent os 6.5 and am trying to make few routes permanent for bond: i have added two routes using below two commands : /sbin/route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.59.160.128 /sbin/route add -net 0.0.0.0 netmask 0.0.0.0 gw 49.44.52.90 post which route command output is... (5 Replies)
Discussion started by: omkar.jadhav
5 Replies

2. Red Hat

How to Find all the SSL certs on a give host Cent OS

Hi I am trying to find all the ssl certs installed/located on cent os Host , Please help . (1 Reply)
Discussion started by: smartguyz2012
1 Replies

3. Red Hat

AD Intergration with Cent OS 6

Hello, I am integration AD authentication to Cent OS 6 servers. I am running to this error when I tried to join with AD server. error message : # net ads join -U 504783 Host is not configured as a member server. Invalid configuration. Exiting.... Failed to join domain: This... (0 Replies)
Discussion started by: bobby320
0 Replies

4. Red Hat

SSL/TLS renegotiation DoS -how to disable? Is it advisable to disable?

Hi all Expertise, I have following issue to solve, SSL / TLS Renegotiation DoS (low) 222.225.12.13 Ease of Exploitation Moderate Port 443/tcp Family Miscellaneous Following is the problem description:------------------ Description The remote service encrypts traffic using TLS / SSL and... (2 Replies)
Discussion started by: manalisharmabe
2 Replies

5. Linux

UVFS in Cent OS

Hi, Trying to install Interwoven Teamsite in CentOs 5.4. Found issue in the first step while installing the uvfs . # gmake /usr/bin/gcc -g -O3 -Wall -I. -c -o uvfs_signal.o uvfs_signal.cc gcc: error trying to exec 'cc1plus': execvp: No such file or directory gmake: *** Error 1 # ... (2 Replies)
Discussion started by: rajarshiroy77
2 Replies

6. Shell Programming and Scripting

How to disable Enable/Disable Tab Key

Hi All, I have bash script, so what is sintax script in bash for Enable and Disable Tab Key. Thanks for your help.:( Thanks, Rico (1 Reply)
Discussion started by: carnegiex
1 Replies

7. Red Hat

Installation of Web Logic9.2 on Cent OS5

Hi, Trying to install web logic 9.2 on Cent OS in the Graphical mode. After accepting the license agreement the "Complete" installation is selected.The path for installing the components is mentioned and when clicked on "Next" it hangs and is not proceeding further. Any suggestion or... (0 Replies)
Discussion started by: rajp_8007
0 Replies

8. Linux

how to make a Cent OS package.

I am using Cent OS 5.1. It has a command "yum" to install or update new packeges from a mirror or repository. i am doing installation and configuration of Sun directory server and opensso. i have made a shell script to install and configure both. but now the need is to create a Cent OS packege,... (1 Reply)
Discussion started by: toanilsharma1
1 Replies

9. Shell Programming and Scripting

Chek if a file exists in Ubuntu and Cent OS using shell script

I have tried few examples in the internet but all of them are different and none worked. I need to check if a file exists in a directory if it does not then exit . here is what I have for now $filename ="/usr/local/net/var/lib/directoryservice/sync.disable" if ; then echo "The file exists"... (2 Replies)
Discussion started by: m_kk
2 Replies
Login or Register to Ask a Question