Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1158851 - Cron cartridge: loading of environment variables underquoted
Cron cartridge: loading of environment variables underquoted
Status: CLOSED ERRATA
Product: OpenShift Container Platform
Classification: Red Hat
Component: Image (Show other bugs)
2.2.0
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jason DeTiberus
libra bugs
: Upstream
: 1158868 (view as bug list)
Depends On: 1157830 1158868
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-30 07:25 EDT by Luke Meyer
Modified: 2014-12-10 08:24 EST (History)
12 users (show)

See Also:
Fixed In Version: openshift-origin-cartridge-cron-1.24.1.1-1
Doc Type: Bug Fix
Doc Text:
Due to a bug in the cron cartridge, environment variables were not properly quoted. This could result in variables being set incorrectly when loaded by gear cron jobs. This bug fix updates the cron cartridge script that handles running the jobs, and as a result, variables are now set correctly. After applying this update, a cartridge upgrade is required.
Story Points: ---
Clone Of: 1157830
Environment:
Last Closed: 2014-12-10 08:24:49 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1979 normal SHIPPED_LIVE Red Hat OpenShift Enterprise 2.2.2 bug fix and enhancement update 2014-12-10 13:23:46 EST

  None (edit)
Description Luke Meyer 2014-10-30 07:25:34 EDT
+++ This bug was initially created as a clone of Bug #1157830 +++

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)"

--- Additional comment from Vojtech Vitek on 2014-10-29 20:09:27 EDT ---

Hey Daniel, thanks for this bug report and the provided fix. Much appreciated!

--- Additional comment from Vojtech Vitek on 2014-10-29 20:12:24 EDT ---

CC'ing Enterprise guys per comment 0, since user verified this bug on OpenShift Enterprise 2.0.8.

--- Additional comment from Vojtech Vitek on 2014-10-29 21:04:40 EDT ---

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
```

--- Additional comment from Vojtech Vitek on 2014-10-29 21:05:04 EDT ---

https://github.com/openshift/origin-server/pull/5915
Comment 2 Brenton Leanhardt 2014-10-30 08:57:31 EDT
*** Bug 1158868 has been marked as a duplicate of this bug. ***
Comment 4 Gaoyun Pei 2014-11-25 01:01:40 EST
verify this bug on puddle 2.2/2014-11-24.3 with package openshift-origin-cartridge-cron-1.24.1.1-1.el6op.noarch

1. rhc app create test1 php-5.3 cron-1.4

2. Create a minutely cron job in .openshift/cron/minutely/env.sh as follow:

#! /bin/sh

env >/tmp/env.txt

3. rhc env set NAME="John Doe" -a test1
   
[root@broker test1]# rhc ssh test1 "cat /tmp/env.txt | grep NAME=Jo"
NAME=John Doe
Comment 6 errata-xmlrpc 2014-12-10 08:24:49 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2014-1979.html

Note You need to log in before you can comment on or make changes to this bug.