Open jalvarezferr opened 8 months ago
Reviweing the code. Same seems to apply to the other values set to JAVA_TOOL_OPTIONS about the metada-keystore
, and in general all the variables exported here:
Fixing it in shell will be a nightmare and probably open the door for regressions or we'll simply miss some use-cases.
I think we'd better move the JAVA_TOOL_OPTIONS
off to a systemd unit override. It is more secure and avoids dealing with files created in one role from another one. However the counter part is that it's not possible to further expand env vars within a systemd Environment=
, so the values can only be static. That would break anything set in the user's profile for instance.
Other suggestions?
Came back to this and foud this works:
#!/bin/bash
export JAVA_OPTS="-version \$JAVA_OPTS"
export JAVA_TOOL_OPTIONS="-Dalfresco.secureComms.secret=D_i0ftP\$example>66Vp"
java $JAVA_OPTS
Produces:
~# ./test.sh
Picked up JAVA_TOOL_OPTIONS: -Dalfresco.secureComms.secret=D_i0ftP$example>66Vp
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
Would just require to sanitize the every value escaping the $
signs. Maybe something like (untested):
- name: Add additional env vars to tomcat.sh
ansible.builtin.lineinfile:
path: "{{ binaries_folder }}/tomcat.sh"
insertafter: 'CATALINA_OPTS'
line: export {{ item.key }}="{{ item.value | replace(\"$\",\"\\$\") | join(' ') }}"
owner: "{{ username }}"
group: "{{ group_name }}"
loop: >-
{{ acs_environment
| ansible.builtin.combine(acs_secure_environment
| default(None), list_merge='prepend')
| dict2items }}
Bug description
The SOLR shared secret is configured both for the repository and for SOLR through the
JAVA_TOOL_OPTIONS
. In both cases it is set in a shell script (tomcat.sh or solr.sh) in this way:Which results in, for example:
As the example contains a $ sign, the shell script will process the string and result in:
Which end up being the secret value set for both repository and SOLR. As the value matches, it operationally works, but breaks any attempt to access the SOLR in other way.
A simple way to test it:
Will output:
Whereas:
Gives the correct result:
Target OS
Any
Host OS
Any
Playbook version
Any (ACS vertion 7.2+)
Ansible error
Not relevant
Ansible context
Not relevant
ansible --version
Not relevant
ansible-config dump --only-changed
Not relevant
ansible-inventory -i your_inventory_file --graph
Not relevant
pip list
Not relevant