The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search and replace with restriction (awk, sed) knoxo Shell Programming and Scripting 10 04-02-2008 04:01 AM
how to restriction directory size in solaris nibiru78 SUN Solaris 3 02-07-2008 07:39 PM
FTP Restriction mduweik SUN Solaris 0 02-28-2006 11:38 AM
Restriction to User gelbvonn Filesystems, Disks and Memory 5 09-10-2004 04:39 PM
Restriction for more than one user kayode Shell Programming and Scripting 7 03-28-2003 11:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-11-2005
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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 (permalink)  
Old 07-11-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0