I'm curious whether you can solve your problem by simply setting
TERM and HOME in /etc/profile.  It looks to me like it should be
read, given that you've started ash with "-/bin/ash" in inittab.

I haven't thought all that hard about this, but from looking at
the code, and your requirements (which are surprising to me, but
maybe shouldn't be), perhaps the best busybox change would be
a new FEATURE_INIT_INHERIT_ENVIRONMENT, which prevents init from
setting any environment at all.  I assume your boot code
could set PATH and SHELL as well as TERM and HOME?

paul

jkm wrote:
 > Dear BusyBox devs,
 > 
 > Could you take a look at this Alpine Linux issue?
 > https://gitlab.alpinelinux.org/alpine/aports/-/issues/13578
 > 
 > I believe that init command from BusyBox overrides HOME and TERM 
 > environment variables that were set in boot params.
 > 
 > As a result, the following env vars that were set in boot params:
 > HOME=/root
 > TERM=linux
 > 
 > are changed to:
 > HOME=/
 > TERM=vt102
 > 
 > I suggest to check if HOME env var is set instead of hardcoding it:
 > 
 >      putenv((char *) "HOME=/");
 > 
 > When it comes to TERM env var, a more sophisticated check is made:
 > 
 > #ifdef VT_OPENQRY
 >      if (ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) != 0) {
 >              /* Not a linux terminal, probably serial console.
 >               * Force the TERM setting to vt102
 >               * if TERM is set to linux (the default) */
 >              if (!s || strcmp(s, "linux") == 0)
 >                      putenv((char*)"TERM=vt102");
 > # if !ENABLE_FEATURE_INIT_SYSLOG
 >              G.log_console = NULL;
 > # endif
 >      } else
 > #endif
 > 
 > Maybe adding a CONFIG_CHECK_VT_OPENQRY in order to make this check 
 > optional would be a good idea?
 > 
 > Please share your thoughts.
 > 
 > Regards,
 > jkm
 > 
 > 
 > _______________________________________________
 > busybox mailing list
 > busybox@busybox.net
 > http://lists.busybox.net/mailman/listinfo/busybox
 > 


=----------------------
paul fox, p...@foxharp.boston.ma.us (arlington, ma)

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to