Fix for /etc/profile.d/prompt.sh
Prod-Related: PROD-34351
Change-Id: I17737dcc73f5fc685b0519c2350db123eb64c6d6
diff --git a/linux/files/prompt.sh b/linux/files/prompt.sh
index 27061d1..0f74fef 100644
--- a/linux/files/prompt.sh
+++ b/linux/files/prompt.sh
@@ -1,5 +1,4 @@
-{%- from "linux/map.jinja" import system with context %}
-
+{%- from "linux/map.jinja" import system with context -%}
# Don't set special prompt when not using Bash or ZSH
[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0
@@ -7,14 +6,15 @@
[[ $- == *i* ]] || return 0
{%- for user, prompt in system.prompt.items() %}
-{% if user != "default" %}
-if [ "$USERNAME" == "{{ user }}" ]; then
- export PS1="{{ prompt }} "
- return 0
+ {%- if user != "default" %}
+if $(id -u {{ user }} >/dev/null 2>&1); then
+ if [ $(id -u) -eq $(id -u {{ user }}) ]; then
+ export PS1="{{ prompt }} "
+ return 0
+ fi
fi
-{% endif %}
+ {%- endif %}
{%- endfor %}
-
-{% if system.prompt.default is defined %}
+{%- if system.prompt.default is defined %}
export PS1="{{ system.prompt.default }} "
{%- endif %}