Bug 9986

Summary: "halt" from login prompt does not work anymore
Product: Busybox Reporter: Ronald Wahl <ronald.wahl>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: Fix for the issue

Description Ronald Wahl 2017-06-28 14:21:05 UTC
Created attachment 7081 [details]
Fix for the issue

I have the following in my /etc/passwd:

halt::0:0:root:/sbin:/sbin/halt

After updating from 1.23.2 to 1.26.2 this does not work anymore:

XXX.XXX.XXX.XXX login: halt
-halt: Invalid argument

Reason is that applet_name is regenerated from argv[0] after removing the leading dash. I attach a patch that works for me...

(side note: the bugtracker is not up-to-date regading Busybox versions - it ends at 1.24.x.)
Comment 1 Denys Vlasenko 2017-07-07 17:19:17 UTC
Let's just pass applet name to run_applet_no_and_exit()?
This allows to not do pathname stripping twice, too:

static NORETURN void run_applet_and_exit(const char *name, char **argv)
...
        {
                int applet = find_applet_by_name(name);
                if (applet >= 0)
-                       run_applet_no_and_exit(applet, argv);
+                       run_applet_no_and_exit(applet, name, argv);

...

void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv)
 {
...
        /* Reinit some shared global data */
        xfunc_error_retval = EXIT_FAILURE;
-       applet_name = bb_get_last_path_component_nostrip(argv[0]);
+       /*
+        * We do not use argv[0]: do not want to repeat massaging of
+        * "-/sbin/halt" -> "halt", for example.
+        */
+       applet_name = name;


fixed in git. Please test.
Comment 2 Ronald Wahl 2017-07-10 08:41:42 UTC
Seems to work. Thx!