ash fails to read $HOME/.profile

Tito farmatito at tiscali.it
Sun Jun 25 20:01:34 UTC 2017



On 06/25/2017 04:20 PM, KP.Kirchdoerfer wrote:
> HI;
>
> Am Samstag, 24. Juni 2017, 22:03:36 schrieb Tito:
>> On 06/24/2017 06:21 PM, KP.Kirchdoerfer wrote:
>>> Hi;
>>>
>>> I'm using busybox 1.25.1 and when loggingin as root it successfully reads
>>> /root/.profile.
>>>
>>> Running latest busybox snapshot this fails due to this commit
>>>
>>> https://git.busybox.net/busybox/commit/shell?id=2eb0a7e1b9a579ba34e4780c9e
>>> d8e74f38bc6b85
>>>
>>> What can be wrong on my side and needs to be changed for a newer busybox
>>> version?
>>>
>>> TIA kp
>>
>
>> Hi,
>> is the HOME var set correctly in the environment after login in as
>> set in the users' /etc/passwd entry?
>
> The file question is /root/.profile:;
>
>> Like e.g:
>>
>> HOME='/home/tito'
>
> env shows:
> HOME=/root
>
>> Is the /etc/passwd file entry correct?
>>
>> tito:x:1000:1000:tito,,,:/home/tito:/bin/bash
>
> Even though mine looked like this one
> root:x:0:0:root:/root:/bin/sh
>
> I've changed to
> root:x:0:0:root,,,:/root:/bin/sh
>
> but makes no difference.
>
> I've thought also adding ENV to the code is an addition and is an "either
> (~/.profile), or(ENV)"...?
>
> regards kp
>
>>
>>
>> Ciao,
>> Tito
Hi,

could you try to add this debug code and then try to login.

diff -uN shell/ash.c shell/ash.c.tito
--- shell/ash.c 2017-06-25 21:52:49.156426570 +0200
+++ shell/ash.c.tito    2017-06-25 21:43:51.000000000 +0200
@@ -13515,7 +13515,9 @@
  static void
  read_profile(const char *name)
  {
+       ash_msg("%s", name); /* Tito */
         name = expandstr(name);
+       ash_msg("%s", name); /* Tito */
         if (setinputfile(name, INPUT_PUSH_FILE | INPUT_NOFILE_OK) < 0)
                 return;
         cmdloop(0);
@@ -13623,7 +13625,7 @@
                 isloginsh = 1;
         if (isloginsh) {
                 const char *hp;
-
+ash_msg("Loginsh"); /* tito*/
                 state = 1;
                 read_profile("/etc/profile");
   state1:
----------------------------------------------------------------------

I did it, copied the busybox binary to /bin/ash
changed the login shell for root in /etc/passwd to /bin/ash
and after login got:

-ash: Loginsh
-ash: /etc/profile
-ash: /etc/profile
-ash: $HOME/.profile
-ash: /root/.profile

So on debian 8 with latest busybox from git it seems to work correctly.
I'm curious to see what it does print out for you.

Hope this helps,

Ciao,
Tito





More information about the busybox mailing list