libuname 1.0.0 -------------- (http://www.bstern.org/libuname/) This is primarily an intercept library to trap uname(2) calls and lie. It was inspired by an email from Mordechai T. Abzug on dc.sage, wherein an installer was erroneously bombing out because Morty was running a newer version of Solaris than the program thought it could deal with. In other words, this is mostly proof-of-concept code rather than anything overwhelming. The basis for the actual interception comes from installwatch, which uses much the same mechanism so that "make install" can be logged. This program is under the GNU Public License - see the file LICENSE that ought to have accompanied this README. If somehow it did not, see http://www.gnu.org/licenses/gpl.txt for the complete text. Building: The supplied makefile is compatible with Solaris make and with GNU make. It does depend upon uname(1) not lying to it, which is hilarious, and it needs GCC, because I don't have a copy of Forte. If you are: On Solaris, with Solaris binutils: It should just work. Let me know if it doesn't, please, with a paste of all of the output from make. On Linux, with GNU binutils: Ditto. On Solaris, with GNU binutils: You need to to build your GCC so that it does not need GNU binutils, and then uninstall them. Otherwise, it will all end in tears. You'll thank me, one day. In the mean time, you should probably muck with the makefile so that it uses the link line for Linux. There is a simple way to tell GCC to build a shared library without any of this external knowledge of which ld is in use, but every time I tried under Solaris with GCC 3.3.4, it insisted on linking in libgcc_s.so, which was Not Acceptable. If you know how to do this without the libgcc dependency, please let me know. I recommend copying the final file to /usr/local/libexec (or, if you built 64-bit, /usr/local/libexec/sparcv9), but it's largely irrelevant. Those of you running Solaris can run "make sysinfo" to get a little binary that behaves like the sysinfo(2) call. Run it with -h or --help for information on how to use it. Using libuname: Set the environment variable LIBUNAME so that it contains the various elements you want to synthesize. The special element * means "don't override this value." For example, in bash, LD_PRELOAD=$PWD/libuname.so LIBUNAME='*;*;*;*;*;*;*' uname -a is identical to uname -a Note that libuname.so must have the same bitness as the target binary. If you are loading a v9 binary, you will need the second CFLAGS line in the Makefile (and a 3.3 or later GCC). Examples: $ uname -a SunOS foo 5.7 Generic_106541-40 sun4u sparc SUNW,Ultra-5_10 $ LD_PRELOAD=$PWD/libuname.so LIBUNAME='*;*;*;*;*;*;*' uname -a SunOS foo 5.7 Generic_106541-40 sun4u sparc SUNW,Ultra-5_10 $ LD_PRELOAD=$PWD/libuname.so \ > LIBUNAME='Linux;bar;2.6.15;#1;Mon Feb 37 22:33:44 UTC 2006;i686;unknown' \ > uname -a Linux bar 2.6.15 #1 Mon Feb 37 22:33:44 UTC 2006 i686 unknown Solaris uname -a: SunOS foo 5.7 Generic_106541-40 sun4u sparc SUNW,Ultra-5_10 ----- --- --- ----------------- ----- ----- --------------- uname -s -n -r -v -m -p -i Linux uname: -a Linux bar 2.6.15 #1 Mon Feb 37 22:33:44 UTC 2006 i686 unknown ----- --- ------ ------------------------------- ---- ------- uname -s -n -r -v -m -p Bugs: Solaris' "uname -X" is not fully overriddable. Misfeatures: On Linux, there does not appear to be a way to override the "unknown" that GNU's "uname -p" returns. This is a vicissitude of life. GNU uname does not take "-i", so the seventh field in LIBUNAME is ignored. libuname will still complain if it is not present, though. I recommend that you use a * for the 7th field. libuname complains to stderr if there is any sort of oddity that it encounters. If libuname cannot find uname(2), it will messily die when the application using it tries to call uname(). Under Solaris, the same thing will happen if sysinfo(2) is not found. This is not libuname's fault, in reality. On the one hand, the function calls should be found unless the OS is in real trouble, and on the other hand, no proper application should be linked against calls that do not appear in the image at load time if libuname were not in the mix. You cannot use LD_PRELOAD with suid or sgid binaries, in most environments. As always, be careful when you muck with the system's idea of the OS version or type or whatever. If you destroy all of your precious data, or even your server, that's not my fault. Don't shoot yourself in the foot, and be sure of the results of your actions before acting. The "no warranty bit" in the GNU GPL is for real. Keep your stick on the ice. I'm pulling for you. Ben Stern bstern@bstern.org