Description of problem: The loading of environment variables (system and user defined) is underquoted, resulting in unwanted word splitting and filename expansion. Version-Release number of selected component (if applicable): OpenShift Online as of 10-27-2014. How reproducible: Always Steps to Reproduce: 1. rhc env set NAME="John Doe" 2. Add cron cartridge to any OpenShift app 3. Create cron job .openshift/cron/minutely/env.sh as follows: #! /bin/sh env >/tmp/env.txt 4. Wait a minute 5. grep ^NAME= /tmp/env.txt Actual results: NAME=John Expected results: NAME=John Doe Additional info: Naturally the bug also appears on OpenShift Enterprise. Verified with OpenShift Enterprise 2.0.8. The culprits seem to be the following lines in '/usr/libexec/openshift/cartridges/cron/bin/cron_runjobs.sh' of the cron cartridge: local contents=$(< $1) export $key=$(< $1) which should instead read: local contents="$(< $1)" export $key="$(< $1)"
Hey Daniel, thanks for this bug report and the provided fix. Much appreciated!
Steps to reproduce: ``` rhc app create php php-5.3 rhc cartridge-add cron --app php cd php mkdir -p .openshift/cron/minutely echo -e "#!/bin/sh\nenv>/tmp/env.txt" > .openshift/cron/minutely/env.sh chmod +x .openshift/cron/minutely/env.sh git commit -ama git push rhc env set NAME="John Doe" --app php #Bug: rhc ssh php "cat /tmp/env.txt | grep NAME=Jo" NAME=John #Fix applied: rhc ssh php "cat /tmp/env.txt | grep NAME=Jo" NAME=John Doe ```
https://github.com/openshift/origin-server/pull/5915
Commit pushed to master at https://github.com/openshift/origin-server https://github.com/openshift/origin-server/commit/3b8cb83b5893cc2c4ef84249b890220a938b8768 Fix malformed ENV VARs in Cron Bug 1157830 - https://bugzilla.redhat.com/show_bug.cgi?id=1157830
Verified on devenv-stage_1085, the bug is fixed and the env value can be loaded correctly by cron [php1-jhou.dev.rhcloud.com 54535e8e84bceaf51e000001]\> cat /tmp/env.txt | grep NAME=Jo NAME=John Doe