support "#!/bin/busybox"-style wrappers. Needed for SELinux.
[oweals/busybox.git] / applets / applets.c
index 6de6db3cd3b8c22c7bb03e58d60d78d76f3fd5f7..c2040b9a3d29e3220b9e08c40e1e4c218a117b5c 100644 (file)
@@ -600,9 +600,10 @@ static int busybox_main(char **argv)
                /* "busybox <applet> arg1 arg2 ..." */
                argv++;
        }
-       /* we want "<argv[0]>: applet not found", not "busybox: ..." */
-       applet_name = argv[0];
-       run_applet_and_exit(argv[0], argv);
+       /* We support "busybox /a/path/to/applet args..." too. Allows for
+        * "#!/bin/busybox"-style wrappers */
+       applet_name = bb_get_last_path_component(argv[0]);
+       run_applet_and_exit(applet_name, argv);
        bb_error_msg_and_die("applet not found");
 }