Restrict a user from Executing particular command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Restrict a user from Executing particular command
# 1  
Old 12-08-2015
Restrict a user from Executing particular command

hi

how to restrict a user ro run rm command.

In this scenario we have a user/group has below in sudoers

Code:
user ALL=(ALL) ALL

is there a way to restrict the user from just executing rm command
# 2  
Old 12-08-2015
You could, but then there would be a zillion ways a user could go around it. Besides he/she could edit the sudoers file. So no, I don't think it can be done in a satisfactory way.
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 12-08-2015
Quote:
Originally Posted by Scrutinizer
You could, but then there would be a zillion ways a user could go around it. Besides he/she could edit the sudoers file. So no, I don't think it can be done in a satisfactory way.
could you please suggest a way to restrict it , keeping the fact that the use have other ways to go around aside,
# 4  
Old 12-08-2015
Since you have a sudoers file which completely makes security non-existent, this will block rm for a particular user for at least 10 seconds.
It also will, for that user, to break a lot of existing shell script code. So expect a problem ticket from that user saying 'I cannot run "X" '

In the user's home directory change .profile to be owned by root, with 644 protections.

Next at the top of the profile, add the line
Code:
alias rm='/dev/null'

There are other slightly more realistic possibilities using file ACL's on /usr/bin/rm to block the user from executing that file. If you understand ACL's and your system supports them. For example, on Linux try the setfacl command. Check the manual page first.

That user has to logout/login for this to take 'effect' If the user has to run a lot of login scripts from .profile after that alias, there is a good chance the user will not be able to login.

This is NOT a reasonable solution, it is an answer to keep you happy. There is no solution. This whole thing sounds like ignorant management dictating really bad changes. Sorry.

Last edited by jim mcnamara; 12-08-2015 at 10:40 AM..
This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 12-08-2015
Quote:
Originally Posted by robo
hi

how to restrict a user ro run rm command.

In this scenario we have a user/group has below in sudoers

Code:
user ALL=(ALL) ALL

is there a way to restrict the user from just executing rm command
In a sudo context, usually you don't want these kind of "everything" entries. So the best solution is to just have rules for the things you do want the user to be able to do through sudo.

However, back to the general statement.... one way is to create a custom application firewall (e.g. apparmor) and set that new apparmored shell to be the user's shell.

You would need to not only restrict rm, but the ability to start up a different shell (gets very complex at this point since many utilities allow you to spawn a shell.

The better answer is to specific sudo rules for what you want to allow....
This User Gave Thanks to cjcox For This Post:
# 6  
Old 12-08-2015
The OP seems to want an 'answer' that specifcally blocks a command rather than making sudoers changes. cjcox, scrutinizer, and myself all agree that sudoers is the problem. Not access to the rm command.

robo - you should not have sudoers entries like that, because it creates the kind of problems you are trying to work around.
This User Gave Thanks to jim mcnamara For This Post:
# 7  
Old 12-08-2015
some other ways (don't try them, if you don't understand the consequences):

1. rm -f /bin/rm
2. echo '#!/bin/sh' >/bin/rm
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Restrict ssh for particular user

Dear Concern, We want to restrict ssh for particular user "oracle". Our HP UX version is as below. Please advise. # uname -a HP-UX tabsdb02 B.11.31 U ia64 2963363594 unlimited-user license (2 Replies)
Discussion started by: makauser
2 Replies

2. Solaris

How to find IP of user machine executing a particular UNIX command?

Hello, Our applications are deployed in SunOS 5.10 servers. All the team members use a same username/pwd to login to the box. Very often we face issue were we could see that weblogic server instance are KILLED and we are not able to trace who executed kill command. All team members use PUTTY to... (2 Replies)
Discussion started by: santtarius
2 Replies

3. AIX

How to restrict user to a particular directory?

hi, I want to restrict some user access to only 1 directory (including all sub-directories/files in it). can you please explain me, how can we do this? example; Filesystem GB blocks Used Free %Used Mounted on /dev/hd4 2.61 1.02 1.59 40% / /dev/hd2 ... (7 Replies)
Discussion started by: aaron8667
7 Replies

4. Red Hat

Restrict user access

Hi there I have an application user on my system that wants accesses to these file systems as such: rwx: /SAPO /SAPS12 /R3_888 /R3_888B /R3_888F /R3_888R r: /usr/sap these are the existing FS permissions:ownerships: # ls -ld /SAPO (9 Replies)
Discussion started by: hedkandi
9 Replies

5. UNIX for Dummies Questions & Answers

Restrict user access.

Hi All, How can we restrict a particular user access to a particular shell in solaris 10. Thanks in Advance. (5 Replies)
Discussion started by: rama krishna
5 Replies

6. Red Hat

Restrict user to a particular directory

Hi I have a Fedora10 server and i need a particular user to view files only in a particular folder. All other files in other folders having "read" permission for all shouldn't be accessible to this user. Please let me know if ther's a way. Thanks, HG (5 Replies)
Discussion started by: Hari_Ganesh
5 Replies

7. UNIX for Dummies Questions & Answers

Restrict command for an user ?

Hi everyone ! I got "viewer" and "root" user on a *nix computer. When i log in using "viewer" I only can use "df" command. When I try another command like "ls" it say : -bash: ls: command not found I checked permission of "/bin/ls" file, it has excute permission for everyone. Inside home... (4 Replies)
Discussion started by: camus
4 Replies

8. AIX

New user and restrict path

Hello I have a question in Aix 5.3 can I create a user, that only can see a specify path. I mean the user log in the default path its /home/newuser he type cd the path that need to check /example/directory_check but if he wants to go to / or any other path. we can not do this. I only... (1 Reply)
Discussion started by: lo-lp-kl
1 Replies

9. Solaris

How to restrict the perticular command to user

Hi all, I want to restrict the perticular command to user. ex: CD, CP, mv etc ., "A" user cannot user CD, CP, mv commands from his home directory. so please let me know the procedure how to restrict the commands access to user "A". I really thankfull to all.... (3 Replies)
Discussion started by: murthy76
3 Replies

10. Solaris

restrict a user to certain command

Hi all, I am using Sun OS 5.10. I am new to Unix. Is there some way to restrict a specific user to certain command say "/usr/bin/more" ?? for example: I want that user1 can execute more command & user2 can't. Can we somehow edit .profile file in the home directory of user to achieve... (1 Reply)
Discussion started by: vikas027
1 Replies
Login or Register to Ask a Question