LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-08-2009, 11:43 AM   #1
linuxaddict7
LQ Newbie
 
Registered: May 2008
Posts: 17

Rep: Reputation: 0
Question File Locking


I am using webmin to update a file for multiple users. Since many users can update the same file at the same time, one user's change may be overwritten by another user.

Webmin doesn't have any option to lock a file.

Is there a way in OS itself to force the lock, make the change and unlock. I tried using rcs, but that I couldn't make it work.

Any ideas/hints/suggestions appreciated.
 
Old 06-08-2009, 02:54 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by linuxaddict7 View Post
I am using webmin to update a file for multiple users. Since many users can update the same file at the same time, one user's change may be overwritten by another user.

Webmin doesn't have any option to lock a file.

Is there a way in OS itself to force the lock, make the change and unlock. I tried using rcs, but that I couldn't make it work.

Any ideas/hints/suggestions appreciated.
Webmin has had file locking for quite sometime (~2005ish?) in many modules. You might wish to review if the module is already performing locking or not, there are a lot of different methods... flock, dotfile, etc..
 
Old 06-09-2009, 08:55 AM   #3
linuxaddict7
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
I worked with Webmin Support, but they dont have the file locking I am looking. There is a module called file locking, but what it does is, make sure two processes doesn't write the same file corrupt, BUT it allows overwriting.
 
Old 06-09-2009, 07:31 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,241

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
Avoiding corruption is all that file locking can do... as soon you as you release the lock another user can change the file anyway!
Either you want to avoid corruption, or you want to limit who is allowed to change the file (ever). The latter is a different qn and is solved using permissions.
 
Old 06-10-2009, 09:21 AM   #5
linuxaddict7
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
I am not sure how permissions can solve what I am looking for. May be I did not explain correctly.

1. user1 and user2 have access to /tmp/file1
2. Created a custom file editor in webmin so that can edit the files thru browser
3. User1 and User2 open /tmp/file1 at the same time and make changes. When they commit changes, whoever saves last will overwrite previous ones changes.

Now, I want to prevent that. When the file is opened by user1 and user2 tries to open the file, I want to throw some user friendly message.

Kindly let me know if you need more information.


thanks
 
Old 06-10-2009, 08:50 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,241

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
In that case, your custom editor needs to use a locking protocol, and check target file before opening it.
As its a custom program, the protocol can be anything you like.
What lang did you use?
 
Old 06-11-2009, 10:03 AM   #7
linuxaddict7
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
The "custom file editor" is a module in Webmin. I did not write it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in locking file shifter Programming 2 10-08-2008 03:24 PM
Locking and unlocking a file Jacko123 Programming 4 05-18-2007 08:41 AM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 05:35 AM
File locking in Linux xailer Programming 5 12-29-2003 02:00 PM
python; file locking TheLinuxDuck Programming 22 08-05-2003 05:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration