Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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..
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.
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.
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.