Re: Per-process namespaces
Saturday, 13. December 2008, 00:04:42
That reminded me to blog about switchsh, a very useful program (now in sid) to help workaround those programs that believe that /bin/sh is always /bin/bash, in other words: it bind-mounts bash as /bin/sh.
Package description follows:
Small program to bind-mount bash as /bin/sh for its child processes.
It can be used when bash is not the default shell interpreter but a given
program makes use of bashisms (features not required by Policy for sh) and one
wants to run it without changing (or can not change) the default sh.
Let's take a look at how switchsh can help us:
$ cat evil_script.sh #!/bin/sh echo -ne "Hello!\nPlease enter your name: " read echo "So, you are $REPLY, right?"
$ readlink /bin/sh
dash
$ ./evil_script.sh
-ne Hello!
Please enter your name:
read: 4: arg count
So, you are , right?
$ switchsh ./evil_script.sh
Hello!
Please enter your name: Raphael
So, you are Raphael, right?
But lets consider the following case:
$ cat evil_script.pl
#!/usr/bin/perl -W
my $res = `git gc &>/dev/null`;
if ($? eq 0) {
print "Done\n";
} else {
print STDERR "bang! something went wrong\n";
}
$ ./evil_script.pl
fatal: Not a git repository
Done
$ switchsh ./evil_script.pl
bang! something went wrong
But what happens when bashisms are used on a binary object? Say in OpenOffice.org, in X.org, Wine, or any other large project that take not less than a couple of hours to build in a "normal" machine? you really want to have switchsh in those cases (and file a bug as soon as you notice that running a program with and without switchsh makes it behave differently).







