[PATCH] Re: ash fails to read $HOME/.profile
KP.Kirchdoerfer
kapeka at bering-uclibc.de
Tue Jun 27 15:01:17 UTC 2017
Am Montag, 26. Juni 2017, 22:11:41 schrieb Tito:
> On 06/26/2017 09:07 PM, Tito wrote:
> > On 06/26/2017 06:37 PM, KP.Kirchdoerfer wrote:
> >> Am Sonntag, 25. Juni 2017, 22:01:34 schrieb Tito:
> >>> 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=2eb0a7e1b9a579ba34e47
> >>>>>> 80c
> >>>>>>
> >>>>>> 9e
> >>>>>> 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.
> >>
> >> Thx for your help!
> >>
> >> I did;
> >> first with shell sh in /etc/passwd linked to ash, second with /bin/ash in
> >> /etc/passwd
> >>
> >> -sh: Loginsh
> >> -sh: /etc/profile
> >> -sh: /etc/profile
> >>
> >> Type in help if you are really lost
> >>
> >> -sh: $HOME/.profile
> >> -sh:$HOME/.profile
> >>
> >> -ash: Loginsh
> >> -ash: /etc/profile
> >> -ash: /etc/profile
> >>
> >> Type in help if you are really lost
> >>
> >> -ash: $HOME/.profile
> >> -ash:$HOME/.profile
> >>
> >> The line "Type in help if you are really lost" is from /etc/profile
> >> see below
> >>
> >> Running "env" just after login show
> >> HOME=/root
> >>
> >> /sbin/init is a link to busybox.
> >>
> >> kp
> >>
> >> PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
> >> LD_LIBRARY_PATH="/usr/local/lib:/usr/lib:/lib"
> >> HOSTNAME="$(hostname)"
> >>
> >> #Set the prompt
> >> PS1="$HOSTNAME$ "
> >>
> >> EDITOR=e3ne
> >>
> >> umask 022
> >> alias dir="ls"
> >> alias vdir="ls -l"
> >> alias ll="ls -l"
> >> alias d="ls"
> >> alias v="ls -l"
> >> alias da="ls -a"
> >> alias va="ls -la"
> >>
> >> alias m="more"
> >> alias +="more"
> >>
> >> alias lo="exit"
> >>
> >> alias w="uptime; who"
> >>
> >> export PATH LD_LIBRARY_PATH HOSTNAME PS1 EDITOR
> >>
> >> echo
> >> echo "Type in help if you are really lost"
> >> # echo
> >
> > Hi,
> > so the $HOME string expansion is failing in your case
> > but not in mine.
> > Looking at code a question arises:
> >
> > #if ENABLE_ASH_EXPAND_PRMT
> > /* expandstr() needs parsing machinery, so it is far away ahead... */
> > static const char *expandstr(const char *ps);
> > #else
> > #define expandstr(s) s
> > #endif
> >
> > Did you enable ENABLE_ASH_EXPAND_PRMT in your config ?
> >
> > Ciao,
> > Tito
> > _______________________________________________
> > busybox mailing list
> > busybox at busybox.net
> > http://lists.busybox.net/mailman/listinfo/busybox
>
> Hi,
> the attached patch should fix the "ash fails to read $HOME/.profile" bug
> when ENABLE_ASH_EXPAND_PRMT is not set.
> Kp could you please test if it fixes your problem when
> ENABLE_ASH_EXPAND_PRMT is not set?
done; and works fine.
thx kp
> Ciao,
> Tito
>
> --- shell/ash.c.orig 2017-06-25 22:04:07.000000000 +0200
> +++ shell/ash.c 2017-06-26 22:09:29.245454443 +0200
> @@ -13629,8 +13629,15 @@ int ash_main(int argc UNUSED_PARAM, char
> state1:
> state = 2;
> hp = lookupvar("HOME");
> - if (hp)
> + if (hp) {
> +#if ENABLE_ASH_EXPAND_PRMT
> read_profile("$HOME/.profile");
> +#else
> + hp = concat_path_file(hp, ".profile");
> + read_profile(hp);
> + free((char*)hp);
> +#endif
> + }
> }
> state2:
> state = 3;
More information about the busybox
mailing list