Bug 9986 - "halt" from login prompt does not work anymore
Summary: "halt" from login prompt does not work anymore
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-28 14:21 UTC by Ronald Wahl
Modified: 2017-07-10 08:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Fix for the issue (1.27 KB, patch)
2017-06-28 14:21 UTC, Ronald Wahl
Details

Note You need to log in before you can comment on or make changes to this bug.
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!