Solved

How to restrict Multiple user edits to single file from multiple session in linux.

Posted on 2011-03-16
7
352 Views
Last Modified: 2012-05-11
I want to restrict multiple user edits to single file from multiple session in linux, how can i do this ??
0
Comment
Question by:sudhirgoogle
7 Comments
 
LVL 10

Expert Comment

by:abbright
ID: 35147050
Create a new group called "editfilegrp".
Put the users you want into this group.
Then change group-ownership of the file to this group: chgrp editfilegrp filename
Change permission to edit the file only for this group: chown u-w,o-w filename
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 275 total points
ID: 35147227
I'd suggest using some kind of source code control system or revision control system.

Mandatory file locking cannot be implemented without programming (C, maybe Perl), taking the original editor binary out of reach, and cooperative/advisory locking (e.g. by some wrapper script to the editor call) is easy to circumvent (just use the original editor binary instead of the wrapper script).

Wikipedia has a list of free revision control software:

http://en.wikipedia.org/wiki/Category:Free_revision_control_software

wmp

0
 
LVL 3

Accepted Solution

by:
Alberto Cortes earned 225 total points
ID: 35148772
Solution:

What you need is a Revision Control environment, where you have control of the file changes and can revert if needed.
I suggest you to check commercial products like IBM Clearcase, or free product like Apache Subversion:
http://en.wikipedia.org/wiki/Clearcase
http://en.wikipedia.org/wiki/Subversion_%28software%29
 
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 40

Expert Comment

by:omarfarid
ID: 35151396
how the file is edited?
0
 
LVL 1

Author Comment

by:sudhirgoogle
ID: 35154197
Thanks for your response. The is being edited using VI editor or VIM
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 275 total points
ID: 35155770
Neither vi nor vim provide a locking mechanism.

Since I assume that you're not willing to write a C program, without Revision Control your only option is a wrapper script to vi and vim providing some kind of locking.

The obvious drawbacks here are:

- Easy circumvention by using the original binary. There is no support for setuid scripts in Linux and most Unixes (except Solaris).
- Easy manual removal of lock files. The concerned user must have full read/write access to them.
- Orphaned locks. Even when trapping all possible signals you can't completely avoid leaving orphaned locks which must be removed manually.
- Ambiguity. Either you're going to lock the filename alone, then only one single file with that name can be edited at a time system-wide, regardless of which directory it is in, or you're going to lock the full path, then a simple cd to the respective directory and starting vi against the filename alone would circumvent the lock.

wmp
0
 
LVL 1

Author Closing Comment

by:sudhirgoogle
ID: 35735761
Not able to implement.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question