Why isn't FEATURE_SH_STANDALONE considered in BB_EXECVP()?

dietmar.schindler at manroland-web.com dietmar.schindler at manroland-web.com
Wed Apr 2 12:00:12 UTC 2014


On the one hand, in shell/ash.c we have:
---
static void
tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char **envp)
{
#if ENABLE_FEATURE_SH_STANDALONE
        if (applet_no >= 0) {
                if (APPLET_IS_NOEXEC(applet_no)) {
                        clearenv();
                        while (*envp)
                                putenv(*envp++);
                        run_applet_no_and_exit(applet_no, argv);
                }
                /* re-exec ourselves with the new arguments */
                execve(bb_busybox_exec_path, argv, envp);
                /* If they called chroot or otherwise made the binary no longer
                 * executable, fall through */
        }
#endif
[...]
}
---
The invocation of run_applet_no_and_exit() allows us to execute busybox NOEXEC applets from ash even if the busybox binary is no longer accessible.

On the other hand, in libbb/execable.c we have:
---
#if ENABLE_FEATURE_PREFER_APPLETS
/* just like the real execvp, but try to launch an applet named 'file' first */
int FAST_FUNC BB_EXECVP(const char *file, char *const argv[])
{
        if (find_applet_by_name(file) >= 0)
                execvp(bb_busybox_exec_path, argv);
        return execvp(file, argv);
}
#endif
---
Here, regardless of FEATURE_SH_STANDALONE only execvp() is called. This leads to cases where applets are not executed, for (contrived) example:

    0>sudo busybox chroot /var/tmp rm /makefile.swp
    chroot: can't execute 'rm': No such file or directory

Why doesn't BB_EXECVP() take FEATURE_SH_STANDALONE into account and handle it similar to tryexec()?

--
Best regards,
Dietmar Schindler
________________________________
manroland web systems GmbH -- Management Board: Eckhard Hoerner-Marass (Spokesman), Joern Gossé
Registered Office: Augsburg -- Trade Register: AG Augsburg -- HRB-No.: 26816 -- VAT: DE281389840

Confidentiality note:
This eMail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any use or dissemination of this communication is strictly prohibited. If you have received this eMail in error, then please delete this eMail.

! Please consider your environmental responsibility before printing this eMail !
________________________________


More information about the busybox mailing list