Skip to content

Commit c79eeb4

Browse files
committed
Source /etc/environment the same way as pam_env:
https://github.com/linux-pam/linux-pam/blob/master/modules/pam_env/pam_env.c Signed-off-by: Jan Dubois <[email protected]>
1 parent d03f921 commit c79eeb4

File tree

1 file changed

+9
-1
lines changed
  • pkg/cidata/cidata.TEMPLATE.d

1 file changed

+9
-1
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ while read -r line; do export "$line"; done <"${LIMA_CIDATA_MNT}"/lima.env
1414

1515
# shellcheck disable=SC2163
1616
while read -r line; do
17-
[ "$(expr "$line" : '#')" -eq 0 ] && export "$line"
17+
# pam_env implementation:
18+
# - '#' is treated the same as newline; terminates value
19+
# - skip leading tabs and spaces
20+
# - skip leading "export " prefix (only single space)
21+
# - skip leading quote ('\'' or '"') on the value side
22+
# - skip trailing quote only if leading quote has been skipped;
23+
# quotes don't need to match; trailing quote may be omitted
24+
line="$(echo "$line" | sed -E "s/^[ \\t]*(export )?//; s/#.*//; s/(^[^=]+=)[\"'](.*[^\"'])?[\"']?$/\1\2/")"
25+
[ -n "$line" ] && export "$line"
1826
done <"${LIMA_CIDATA_MNT}"/etc_environment
1927

2028
CODE=0

0 commit comments

Comments
 (0)