-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install the shared library .so file as executable #1525
Conversation
- Using INSTALL instead of INSTALL_DATA for the shared library This change would allow the compiled program to run on more secure systems such as HP_UX. Currently, executables linked to non-executable .so would result in a core dump for attempting to execute codes that are not marked as executable.
- upgrade dependency htslib to 1.16 - also fixes htslib so permission issue (samtools/htslib#1525)
I don't like the blanket approach of marking it as executable on all environments. A quick check on our ubuntu servers:
Executable libraries would be deemed as wrong here as non-executable elsewhere, and likely lead to similar tweaks in the distribution package to chmod them back again. I wonder if there is a way we can determine the correct policy at configure time. Even if it's just a uname / lsb_release type command to identify the OS. |
I was going to say you could invent an |
This stack exchange question discusses the library permissions difference between Debian and Red Hat based systems. I think I'm more on the Debian side here, given that trying to run libhts.so results in an instant core dump. Unfortunately I don't think there's an easy way of probing to see if a platform desires executable shared libraries. We could add a configure option to make it easier to choose. Or possibly we could add an entry point so that it does something more useful than dump core, a bit like when you try to run |
Making code changes to permit it to become an executable is tail wagging the dog. I'd just be in favour of adding a Makefile As John points out, right now you could just use Edit, also I wasn't saying we need configure to do things like my find command and try to statistically work out what the standard policy is for this system. Rather something naive like "uname -sr" and look for hpux is probably sufficient. There's no requirement for execute bit on redhat, so whether or not we do it is largely irrelevant there. |
My reasoning behind marking it as +x by default is that it avoids usability issue for those running an OS that requires ALL executable code, including those inside a .so file and never supposed to be executed directly, being marked as +x. Although most Linux do not require it, RHEL family recommends it, and HP-UX (and potentially some other Unix) do have such requirement. The Debian's reasoning of marking them as non-executable to avoid the user running them in the first place to avoid a core dump when the user tries to execute a file that is not supposed to be executed directly makes sense in the packager's POV as it reduces number of bug reports related to it, but it is eventually the user's fault of executing a shared library instead of the executable. And it is the user that needs more education on "do not execute random files". However it becomes a usability issue when it comes to those on an OS that separates executable code and non-executable code when mapped to the memory based on the +x permission on the filesystem. When a user For a software packager's point of view, they kind of have an idea of what permission is expected for what file in what directories, so they would apply such tweaks with ease. However for an average user with little knowledge on the permission issue, their expectation would likely be:
The lack of +x by default for .so file fails the users on OSes that require +x for all executable code for such expectation. On the other hand, if the INSTALL_LIB defaults the permission to 755, on whatever system the user tries to run it, even those who wish to see a .so file without +x, no error would occur and the user runs the program just fine. And yes, making the .so file come with a __init entry point like libc for some version information is the tail wagging the dog. Don't do that unless there is some compelling issue such as for some reason the majority of user start trying to execute whatever file they found with +x permission set. In this point, I feel that one of the two following way of solving this problem would work better:
Any further ideas? |
I think there is an easy way to test if the platform REQUIRES executable shared libraries though. In However I am not so familiar with autotools and haven't come up with the code implementing such testing. Does anyone think that such test would be helpful? |
- upgrade dependency htslib to 1.16 - also fixes htslib so permission issue (samtools/htslib#1525)
The new LIB_PERM Makefile variable defaults to 644 (as before), but can now be amended to e.g. 755. Updated the INSTALL file with a section for HP-UX explaining how to do this. Fixes samtools#1525
We don't wish to change the default behaviour for operating systems that have conventions on other permissions. While we could attempt some automatic detection, we deemed it as unnecessary effort for a problem with an easy work around already. Instead we simplify the process somewhat with a new |
The new LIB_PERM Makefile variable defaults to 644 (as before), but can now be amended to e.g. 755. Updated the INSTALL file with a section for HP-UX explaining how to do this. Fixes #1525
Executable programs linked to non-executable .so could result in a core dump for attempting to execute codes that are not marked as executable in some systems such as HP_UX.
It is also standard practice of installing such shared objects with +x bit set (755) in RHEL-based distributions - not doing so would get caught by the packaging QA system (non-executable file found in /usr/lib) and rejected. This is currently fixed manually on fedora's building script (https://src.fedoraproject.org/rpms/htslib/blob/rawhide/f/htslib.spec#_79), though I think providing the .so file with +x set in the first place would be better.
One may argue that it offers little benefit to Debian-based distributions as they do allow non-executable .so files, and distributions such as Gentoo would automatically +x all .so installed into /usr/lib64 in the installation step, but making it as permissive as when the .so is produced (by marking codes that were supposed to be executed, although not directly, as executable instead of removing the +x bit in make install) would rarely cause any harm on them.