* [PATCH] base-files: add some safety checks in profile
@ 2016-04-29 10:24 Diego Rondini
0 siblings, 0 replies; only message in thread
From: Diego Rondini @ 2016-04-29 10:24 UTC (permalink / raw)
To: openembedded-core; +Cc: Diego Rondini
Add some safety checks when sourcing files in /etc/profile.d/, in particular:
- source only *.sh files, not every file. This is the practice in use in both
Fedora and Debian/Ubuntu (see
https://help.ubuntu.com/community/EnvironmentVariables#A.2Fetc.2Fprofile.d.2F.2A.sh);
- check the input is actually a file and is readable. This check is especially
important if profile.d is empty, as "*.sh" will get expanded only if
profile.d is not empty. Previously if profile.d was present but empty,
"/etc/profile.d/*" was sourced causing errors on login and breaking stuff, for
example X startup.
Signed-off-by: Diego Rondini <diego.ml@zoho.com>
---
meta/recipes-core/base-files/base-files/profile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
index 53c2680..e98e786 100644
--- a/meta/recipes-core/base-files/base-files/profile
+++ b/meta/recipes-core/base-files/base-files/profile
@@ -20,8 +20,10 @@ if [ "$PS1" ]; then
fi
if [ -d /etc/profile.d ]; then
- for i in /etc/profile.d/* ; do
- . $i
+ for i in /etc/profile.d/*.sh ; do
+ if [ -f $i -a -r $i ]; then
+ . $i
+ fi
done
unset i
fi
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-29 10:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 10:24 [PATCH] base-files: add some safety checks in profile Diego Rondini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.