Directory restriction warning


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Directory restriction warning
# 1  
Old 07-11-2005
Directory restriction warning

Platform: AIX
Shell: KSH

Does anyone have a good way of warning users that when they do a 'vi' in a certain directory that they cannot save any changes in that directory.
For instance, if I have a production id that has all scripts in /myprod/dir, and if anyone comes to this directory and does a 'vi' to edit/view any files there, a message will remind them that they cannot make updates (unless they are logged on as the production id that owns all these files so no warning is shown)?

I don't want to just warn everytime they cd to the prod directory b/c it can be annoying...but if this is the only option then how would you approach it. Some ideas would be nice.

Cheers!
Gianni
# 2  
Old 07-11-2005
You could write a script that would act as a wrapper to vi. Then move the vi binary to some other name such as vi.org. Link the /usr/bin/vi to your script - say /usr/local/bin/vi.wrapper.

Here's a sample vi.wrapper script. It is very simplistic and has no checks for directory permissions. It assumes that all directory permissions will be 775 and works on that.

Code:
#!/bin/sh
filetoedit=$1
user=`ls -ld |awk '{print $3}'`
group=`ls -ld |awk '{print $4}'`

curruser=`whoami`
currgrps=`groups $curruser`

echo $user | grep $curruser > /dev/null 2> /dev/null
if [ $? -ne 0 ]
then
        echo $currgrps | grep $group
        if [ $? -ne 0 ]
        then
                echo you dont have perms to edit files in this directory
        fi
fi
vi.org $filetoedit

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Sudo -s restriction

Is there a way to stop users envoking a root shell with sudo on Solaris 10. I want users to use sudo <cmd> but not sudo -s (5 Replies)
Discussion started by: u20sr
5 Replies

2. AIX

Print queue restriction

Hi, I'm at AIX 5.3, I have a print queue named chqprinter, I want to allow access to print only 2 users to that print queue, jobs printed by all other users to above queue should be deleted. Any idea how to achieve that? ---------- Post updated at 10:33 AM ---------- Previous update was at... (5 Replies)
Discussion started by: tayyabq8
5 Replies

3. Solaris

Directory restriction for specific users on Solaris

Hi all, i have a question about directory accessing. Question: therese is a x user which can login system, x user can only access specific directories on the system, even y directory has r-x access right for OTHER, x user will not access the y directory. this x user must access specific... (4 Replies)
Discussion started by: nibiru78
4 Replies

4. UNIX for Advanced & Expert Users

User restriction

Dear All I had one user called msc. In that i had two folder.xxx and yyy ex: /home/msc/xxx ex: /home/msc/yyy Now i want that msc user only able to access xxx folder only. No other folder should be visible to it. Kindly let me know. How it possile?? Regards Jaydeep (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies

5. AIX

user session restriction

hi, I am facing a problem from the remote system if i login to my AIX5.3 machine as root (thru telnet) the session does not expire for 2 hours even if the session is kept ideal But whenever i do the same thing from some other user then the session is lost within 10 minutes (if session is kept... (2 Replies)
Discussion started by: pchangba
2 Replies

6. UNIX for Dummies Questions & Answers

mailx recipient restriction

maybe a simple question, but i've looked around and not been able to find anything. is there a restriction on how many recipients can be used in a single mailx command? whether it's a numeric restriction or a size restriction (like 256k for the whole recipient parameter). thanks a lot. (6 Replies)
Discussion started by: chris32680
6 Replies

7. Solaris

how to restriction directory size in solaris

how to restrict the size of any directory in solaris. is there any command to give specific file size value for a directory? is there any idea? regards (3 Replies)
Discussion started by: nibiru78
3 Replies

8. Solaris

FTP Restriction

I have a senario and i wonder how to do it ? i used NcFTPd and i dont think its applicable using that application or i didnt know how to configure it. i want to have a user for FTP that user is only restricted to put and get from a certain directory and all sub-directories for that directory,... (0 Replies)
Discussion started by: mduweik
0 Replies

9. Filesystems, Disks and Memory

Restriction to User

Dear all, I am trying to create a new user account that can have the minimum access to the HP-Ux box, as in it only need to perform system info query like bdf and only able to read access system log files but not able to delete any file from any other directory beside it's own user directory... (5 Replies)
Discussion started by: gelbvonn
5 Replies

10. Shell Programming and Scripting

Restriction for more than one user

How do l restrict more than one users on a multiple programming environment using the c shell profile. That is if a user is log-on on one terminal the system should be able to prompt a message if the users attempt to log on on another terminal. I user openserver 5.0.4 with dummy terminals, and also... (7 Replies)
Discussion started by: kayode
7 Replies
Login or Register to Ask a Question