HOME variable in init/init.c

Arkadiusz Drabczyk arkadiusz at drabczyk.org
Sun Sep 16 21:08:45 UTC 2018


On 2018-09-15, Asaf Kahlon <asafka7 at gmail.com> wrote:
> Hello,
>
> I would like to know why HOME was set to "/" at init/init.c (the comment
> above the code just says "Make sure environs is set to something sane")?
> I would expect it to be "/root" considering that USER has been set to
> "root"...
>
> It can lead to different behaviors when running a daemon process as init
> script compared to run it manually (e.g with a Python script which runs
> expanduser).

You can use login applet in your /etc/inittab to have $HOME set to
/root instead of /.  I also do that.

> It would be nice if someone can explain why this value was chosen (or
> whether it's OK to send a patch to change it).

As said earlier it is because / is the only directory that has to
exist.  There is Filesystem Hierarchy Standard
https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf but not
everyone follows it.  I don't think the patch is necessary, current
behaviour is good.
-- 
Arkadiusz Drabczyk <arkadiusz at drabczyk.org>



More information about the busybox mailing list