[BusyBox] Problem executing external commands in BusyBox/ash (0.60.5)

Michael Boman michael.boman at securecirt.com
Thu Nov 7 16:43:03 UTC 2002


First of all I want to apology in advance for the lengthy email.

I have installed (read copied) a few utilities from util-linux (and
e2fsprogs) to my installer disk (live FS on CDROM) togeather with utils
from BusyBox and almost everything works except executing external
(non-BusyBox) commands:

---8<---8<---
# ls -l /bin/sfdisk
-rwxr-xr-x    1 0        0           48912 Nov  7 22:15 /bin/sfdisk
# /bin/sfdisk -l /dev/hda
/bin/sfdisk: No such file or directory
---8<---8<---

strace (strace -f -p <pid-of-ash>) of the ash process (when executing
the above in a chroot enviroment - don't like to type all these
things...) gets me this:

---8<---8<---
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(0, TIOCGWINSZ, {ws_row=53, ws_col=165, ws_xpixel=1011, ws_ypixel=693}) = 0
rt_sigaction(SIGWINCH, {0x8053d90, [WINCH], SA_RESTART}, {SIG_DFL}, 8) = 0
write(1, "# ", 2)                       = 2
read(0, "l", 1)                         = 1
write(1, "l", 1)                        = 1
read(0, "s", 1)                         = 1
write(1, "s", 1)                        = 1
read(0, " ", 1)                         = 1
write(1, " ", 1)                        = 1
read(0, "-", 1)                         = 1
write(1, "-", 1)                        = 1
read(0, "l", 1)                         = 1
write(1, "l", 1)                        = 1
read(0, " ", 1)                         = 1
write(1, " ", 1)                        = 1
read(0, "/", 1)                         = 1
write(1, "/", 1)                        = 1
read(0, "b", 1)                         = 1
write(1, "b", 1)                        = 1
read(0, "i", 1)                         = 1
write(1, "i", 1)                        = 1
read(0, "n", 1)                         = 1
write(1, "n", 1)                        = 1
read(0, "/", 1)                         = 1
write(1, "/", 1)                        = 1
read(0, "s", 1)                         = 1
write(1, "s", 1)                        = 1
read(0, "f", 1)                         = 1
write(1, "f", 1)                        = 1
read(0, "d", 1)                         = 1
write(1, "d", 1)                        = 1
read(0, "i", 1)                         = 1
write(1, "i", 1)                        = 1
read(0, "s", 1)                         = 1
write(1, "s", 1)                        = 1
read(0, "k", 1)                         = 1
write(1, "k", 1)                        = 1
read(0, "\n", 1)                        = 1
write(1, "\n", 1)                       = 1
ioctl(0, TCSETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
rt_sigaction(SIGWINCH, {SIG_DFL}, {0x8053d90, [WINCH], SA_RESTART}, 8) = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=352, ...}) = 0
open(".", O_RDONLY)                     = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 14 entries */, 4096)     = 244
getdents(3, /* 0 entries */, 4096)      = 0
close(3)                                = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=352, ...}) = 0
open(".", O_RDONLY)                     = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 14 entries */, 4096)     = 244
getdents(3, /* 0 entries */, 4096)      = 0
close(3)                                = 0
stat("/bin", {st_mode=S_IFDIR|0755, st_size=432, ...}) = 0
open("/bin", O_RDONLY)                  = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 18 entries */, 4096)     = 304
close(3)                                = 0
fork()                                  = 5537
[pid  5457] wait4(-1,  <unfinished ...>
[pid  5537] rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0
[pid  5537] rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0
[pid  5537] rt_sigaction(SIGTERM, {SIG_DFL}, NULL, 8) = 0
[pid  5537] ioctl(1, TIOCGWINSZ, {ws_row=53, ws_col=165, ws_xpixel=1011, ws_ypixel=693}) = 0
[pid  5537] lstat("/bin/sfdisk", {st_mode=S_IFREG|0755, st_size=48912, ...}) = 0
[pid  5537] open("/etc/passwd", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  5537] open("/etc/group", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  5537] time(NULL)                  = 1036710456
[pid  5537] write(1, "-rwxr-xr-x    1 0        0      "..., 68) = 68
[pid  5537] _exit(0)                    = ?
<... wait4 resumed> [WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 5537
--- SIGCHLD (Child exited) ---
wait4(-1, 0xbffff554, WNOHANG, NULL)    = -1 ECHILD (No child processes)
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(0, TIOCGWINSZ, {ws_row=53, ws_col=165, ws_xpixel=1011, ws_ypixel=693}) = 0
rt_sigaction(SIGWINCH, {0x8053d90, [WINCH], SA_RESTART}, {SIG_DFL}, 8) = 0
write(1, "# ", 2)                       = 2
read(0, "/", 1)                         = 1
write(1, "/", 1)                        = 1
read(0, "b", 1)                         = 1
write(1, "b", 1)                        = 1
read(0, "i", 1)                         = 1
write(1, "i", 1)                        = 1
read(0, "n", 1)                         = 1
write(1, "n", 1)                        = 1
read(0, "/", 1)                         = 1
write(1, "/", 1)                        = 1
read(0, "s", 1)                         = 1
write(1, "s", 1)                        = 1
read(0, "f", 1)                         = 1
write(1, "f", 1)                        = 1
read(0, "d", 1)                         = 1
write(1, "d", 1)                        = 1
read(0, "i", 1)                         = 1
write(1, "i", 1)                        = 1
read(0, "s", 1)                         = 1
write(1, "s", 1)                        = 1
read(0, "k", 1)                         = 1
write(1, "k", 1)                        = 1
read(0, " ", 1)                         = 1
write(1, " ", 1)                        = 1
read(0, "-", 1)                         = 1
write(1, "-", 1)                        = 1
read(0, "l", 1)                         = 1
write(1, "l", 1)                        = 1
read(0, " ", 1)                         = 1
write(1, " ", 1)                        = 1
read(0, "/", 1)                         = 1
write(1, "/", 1)                        = 1
read(0, "d", 1)                         = 1
write(1, "d", 1)                        = 1
read(0, "e", 1)                         = 1
write(1, "e", 1)                        = 1
read(0, "v", 1)                         = 1
write(1, "v", 1)                        = 1
read(0, "/", 1)                         = 1
write(1, "/", 1)                        = 1
read(0, "h", 1)                         = 1
write(1, "h", 1)                        = 1
read(0, "d", 1)                         = 1
write(1, "d", 1)                        = 1
read(0, "a", 1)                         = 1
write(1, "a", 1)                        = 1
read(0, "\n", 1)                        = 1
write(1, "\n", 1)                       = 1
ioctl(0, TCSETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
rt_sigaction(SIGWINCH, {SIG_DFL}, {0x8053d90, [WINCH], SA_RESTART}, 8) = 0
stat("/bin", {st_mode=S_IFDIR|0755, st_size=432, ...}) = 0
open("/bin", O_RDONLY)                  = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 18 entries */, 4096)     = 304
close(3)                                = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=352, ...}) = 0
open(".", O_RDONLY)                     = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 14 entries */, 4096)     = 244
getdents(3, /* 0 entries */, 4096)      = 0
close(3)                                = 0
stat("/dev", {st_mode=S_IFDIR|0755, st_size=7584, ...}) = 0
open("/dev", O_RDONLY)                  = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 256 entries */, 4096)    = 4096
close(3)                                = 0
fork()                                  = 5538
[pid  5457] wait4(-1,  <unfinished ...>
[pid  5538] rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0
[pid  5538] rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0
[pid  5538] rt_sigaction(SIGTERM, {SIG_DFL}, NULL, 8) = 0
[pid  5538] execve("/bin/sfdisk", ["/bin/sfdisk", "-l", "/dev/hda"], [/* 50 vars */]) = -1 ENOENT (No such file or directory)
[pid  5538] write(2, "/bin/sfdisk", 11) = 11
[pid  5538] write(2, ": ", 2)           = 2
[pid  5538] write(2, "No such file or directory", 25) = 25
[pid  5538] write(2, "\n", 1)           = 1
[pid  5538] _exit(127)                  = ?
<... wait4 resumed> [WIFEXITED(s) && WEXITSTATUS(s) == 127], 0, NULL) = 5538
--- SIGCHLD (Child exited) ---
wait4(-1, 0xbffff554, WNOHANG, NULL)    = -1 ECHILD (No child processes)
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(0, TIOCGWINSZ, {ws_row=53, ws_col=165, ws_xpixel=1011, ws_ypixel=693}) = 0
rt_sigaction(SIGWINCH, {0x8053d90, [WINCH], SA_RESTART}, {SIG_DFL}, 8) = 0
---8<---8<---

I have the following stuff enabled in my Config.h (grep ^#define Config.h)

---8<---8<---
#define BB_ASH
#define BB_CHMOD
#define BB_CHROOT
#define BB_ECHO
#define BB_GUNZIP
#define BB_GZIP
#define BB_LS
#define BB_MKSWAP
#define BB_MOUNT
#define BB_MV
#define BB_PIVOT_ROOT
#define BB_RM
#define BB_TAR
#define BB_TEST
#define BB_UMOUNT
#define BB_FEATURE_SH_IS_ASH
#define BB_FEATURE_LS_USERNAME
#define BB_FEATURE_LS_TIMESTAMPS
#define BB_FEATURE_LS_SORTFILES
#define BB_FEATURE_LS_RECURSIVE
#define BB_FEATURE_LS_FOLLOWLINKS
#define BB_FEATURE_MOUNT_FORCE
#define BB_FEATURE_TAR_GZIP 
#define BB_FEATURE_SH_STANDALONE_SHELL
---8<---8<---

and I compile it against uClibc (uClibc-0.9.15) like this:

---8<---8<---
PATH=$BUILDROOT/usr/i386-linux-uclibc/bin:$PATH &&
CHOST="i686-pc-linux-gnu" CFLAGS="-march=i686 -O3 -pipe" CXXFLAGS="-march=i686 -O3 -pipe" make PREFIX=$BUILDROOT/cdrom_fs
CHOST="i686-pc-linux-gnu" CFLAGS="-march=i686 -O3 -pipe" CXXFLAGS="-march=i686 -O3 -pipe" make install PREFIX=$BUILDROOT/cdrom_fs
---8<---8<---

Best regards
 Michael Boman



More information about the busybox mailing list