Re: binfmt_java problems

Andries.Brouwer@cwi.nl
Wed, 15 May 1996 22:42:58 +0200


In linux.dev.kernel H. Peter Anvin writes:

: Im my opinion there is a very serious problems with binfmt_java as
: implemented in the pre2.0 series kernels. This is particularly
: disturbing given the timings, although the problem is technically
: fairly trivial.

: The problem is that it assumes *way* too much about the user space
: environment. All of the following are assumed:

: 1. A /usr partition exists, is writable and/or the version of java
: installed there is appropriate;
: 2. /bin/bash (not even /bin/sh) exists and is appropriate for running
: shell scripts;
: 3. /usr/bin/java and /usr/bin/appletviewer are shell scripts.
: 4. It appears to me that it will not properly handle executing it from
: anywhere but the current directory, since it strips the path from
: the front.

I agree completely. It is very undesirable to have explicit paths
in the kernel. In the good old days the only exception was /etc/init
(/etc/rc, /bin/sh) started as first process, and even in that case
one could specify something else with a "init=..." command line parameter.
However, slowly the number of paths in the kernel increases.

I am aware of (completeness not guaranteed):

(in init/main.c) "/etc/init", "/bin/init", "/sbin/init", "/bin/sh", "/etc/rc"
"HOME=/", "HOME=/usr/root"
"/dev/tty1"
"/linuxrc", "/initrd"

(in fs/binfmt_elf.c) "/usr/lib/libc.so.1"
"/usr/lib/ld.so.1"

(in drivers/block/ide.c - only in a printk)
"/usr/src/linux/drivers/block/MAKEDEV.ide"

(in fs/exec.c) "/sbin/loader"

(in fs/umsdos/inode.c) "/linux"
#define UMSDOS_PSDROOT_NAME "linux"
#define UMSDOS_EMD_FILE "--linux-.---"

#define NCP_MSG_COMMAND "/sbin/nwmsg"

#define _PATH_JAVA "/usr/bin/java"
#define _PATH_APPLET "/usr/bin/appletviewer"
#define _PATH_SH "/bin/bash"

: I would suggest one of the following approaches:

: 1. Easiest: define /sbin/kjavad as a wrapper program ...
: 2. Somewhat harder: use /(s)bin/{java,appletviewer} ...

These still have explicit paths. You would like to avoid that.

: 3. Hardest/most flexible: set the appropriate paths through /proc/sys;
: disable Java binaries unless the paths are set.

: I'll try to hack up #3.

Seems a very good idea. (And not hard at all.)

Andries