Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1931 - Root environment not set up while running /etc/init.d scripts #6862

Closed
openwrt-bot opened this issue Nov 7, 2018 · 2 comments
Closed
Labels

Comments

@openwrt-bot
Copy link

wiltedwalls:

/etc/init.d scripts run as root, which is reflected in the ownership of files created by the scripts. But the environment does NOT have the correct USER=root and HOME=/root

The whole env at runtime is
SHLVL=1
HOME=/
TERM=linux
PATH=/usr/sbin:/usr/bin:/sbin:/bin
PWD=/

I see this on two different model TP Link routers running Openwrt 18.06.1

@openwrt-bot
Copy link
Author

wiltedwalls:

This bug is a problem because commands which as ssh refer to files/directories in the HOME directory, and HOME is not properly set

@openwrt-bot
Copy link
Author

jow-:

You should not rely on user specific environment variables during system init. If you need access to such variables, you must explicitly declare them. Quoting POSIX spec:

HOME - The system shall initialize this variable at the time of login to be a pathname of the user's home directory.

Since during system init no user is logged in, providing a user specific environment would be wrong.

Reference: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant