If one of the shared libraries is used while the application is running, it is written or truncated, then the application will crash. Moving a file or deleting it with "rm" will not crash because the OS (Solaris in this case, but I assume that this is true for Linux and other * nix) is smart enough not to delete the index associated with the file, while any process will be open.
I have a shell script that installs shared libraries. Sometimes it can be used to reinstall versions of shared libraries that have already been installed without first uninstalling it. Since applications can use shared libraries that are already installed, it is important that the script is smart enough to store files or move them to the side (for example, to a “remote” folder in which cron might be empty while we know the applications aren’t will be launched) before installing new ones so that they are not overwritten or truncated.
Unfortunately, recently the application broke up immediately after installation. Coincidence? Hard to say. The real solution here is to switch to a more reliable installation method than the old giant shell script, but it would be nice to have extra protection until a switch is made. Is there a way to wrap a shell script to protect it from overwriting or truncating files (and, ideally, loudly), but still allows them to move around or rm'd?
Standard UNIX file permissions will not do the trick because you cannot distinguish between moving / deleting and rewriting / truncating. Aliases may work, but I'm not sure that all teams should be smooth. I imagine something like truss / strace, except that before each action it checks the filter to see if it really does. I don't need a perfect solution that will work even against an intentionally malicious script.
source
share