Function to silence rm -rf option for my user


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function to silence rm -rf option for my user
# 8  
Old 11-06-2015
Hi,

Thanks Rudic,Ravinder Singh,rabattel,Don Cragun for enlightening me.

as i got the requirement to suppress -rf option for rm command to database user
i don't have sudo or root access so i chosen this way with my limited knowledge.
Thanks once again all for sharing your thoughts.

Thanks
Venkat
# 9  
Old 11-06-2015
IN general, doing what you want ,without creating a chroot jail for that one user, will fail or break existing code for everybody else.

You need to consider - assuming you are on a open source like linux or freeBSD:

1. change the rm source to stop printing, compile it to another directory
2. put the one user in a chroot jail, where the special rm and the rest of /bin /usr/bin and maybe /usr/sbin are in a separate safe location for that user. Only.

Ubuntu example chroot:
https://www.digitalocean.com/communi...untu-12-04-vps
These 2 Users Gave Thanks to jim mcnamara For This Post:
# 10  
Old 11-08-2015
Quote:
Originally Posted by venky.b5
<...>
like below

Code:
source /home/venkat/scripts/test_fun_ls.sh
alias ls='RM_FUNCTION'

<..>
Also Someone please advice me above process is ok or not
Aliasing a rm function to ls is not something i consider "avoid unrequired deletions".
ls is used to list files, not to remove them.
From my point of view, i say this is not only bad coding - but harmfull coding, eventhough the intial idea was to to avoid harms.

And if it is jus for fun, try this:
Code:
alias ls="echo rm ${@:-*};echo Successfully deleted: ${@:-*}"

Cheers
This User Gave Thanks to sea For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Apache 2.4 User/Group option with svcadm

Hello all, Solaris 11. Branch: 0.175.3.35.0.6.0 Asking for some assistance in trying to understand how Apache24 works with svcadm. I used: svccfg -s network/http:apache24 listprop setprop start/user=<rabbit> setprop start/group=<pod> This is also set in... (1 Reply)
Discussion started by: smiloo
1 Replies

2. Shell Programming and Scripting

awk - user function?

Here's a snippit from a script I'm working on srvctl config database | \ awk -F\" '{print "srvctl config database -d " $1 " -a" \ RS "echo =================================================="}' \ > /tmp/x$$.sh chmod 777 /tmp/x$$.sh /tmp/x$$.sh As you can see, I'm piping the... (12 Replies)
Discussion started by: edstevens
12 Replies

3. Shell Programming and Scripting

KSH- perform a function if user selects option from menu

Hi, I have a script that copies a file from one directory to another and compiles it. What I have now is a menu that calls functions and each function compiles the file. I want to have a function that compiles the file at the end of the script if the user selects options 1-3 in the menu, but... (0 Replies)
Discussion started by: amitlib
0 Replies

4. Shell Programming and Scripting

Interactive script to give user option of what text to add

Hello all, I have created a script that will remove the first two lines of one text file (body.txt) and then add the text from a different text file (header.txt) directly to the beginning of the freshly modified body.txt file. It is as follows: #!/bin/bash ## This script will add a header... (2 Replies)
Discussion started by: marcozd
2 Replies

5. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

6. Shell Programming and Scripting

Call Function in .pm as another user

Hello, I need to call a function which reside in some package moudle (.pm) as another user by using su -. Are anyone know how can I do it? Thanks (1 Reply)
Discussion started by: Alalush
1 Replies

7. Shell Programming and Scripting

need help with User Defined Function

Dear Friends, I need a help regarding User defined function in shell script. My problem is as follows: my_func.sh my_funcI(){ grep 'mystring' I.dat } my_funcQ(){ grep 'mystring' Q.dat } myfuncI myfuncQ But As both the function has same function only the... (11 Replies)
Discussion started by: user_prady
11 Replies
Login or Register to Ask a Question