I was assigned to enhance tool in unix solaris...the tool is totaly developed on shell and perl scripts...
The tool is used to change control files....The users are of certain group..
due to many users some people are changing these control files directly by using editors ....they are not using tool to change control files.
In the tool it has feature that it will not allow multiple user to write at a time.
But other user can change by using editors ...So we need to stop this...
Please help me in this regard....
I thought file locking...but dont know how to implement...
in my opinion, you need to tell all people not to edit those files directly, and provide them access to your tools using which they can do the required editing (if your tools are good enough, then they may quit their old habits and start using the tools)
if you are going ahead with fcntl, this is a good place to visit
Since mandatory file locking in *nix is somewhat, well, borked , you could use the common kludge of an independent lockfile for exclusive access per file. The trick there is
making bulletproof the removal of the same based on client behavior, implementing a timed wait, etc..Not impossible, but challenging.
Perhaps you could save the file encrypted, so that editing it has to be a 2-stage process.
Of course, your would have to decrypt it for use too.
Alternatively, you could secure the file so it could not be edited, and then use sudo to access it.
If you did a wrapper on the front, then that could take care of locking.
Another option would be to use NFS to share the file, and then mount it back with extra controls.
Or perhaps you could make the control files binary, so that they need a front-end of your choice to edit.
Or maybe a version control system (eg. RCS) could be used to check in and out the file.
But at the end of the day, essentially you've got a security situation - directory and file permissions should be set so that only designated and authorised persons have access to (view/edit) files, and anything that circumvents this is badly designed and/or implemented.