Conversion from yml to json for user.config.php creates a invalid json object
Cyb3rDudu opened this issue · 7 comments
The json object that is created as parameter for the json_decode call in user.config.php is invalid and so the function return null.
Reproducible on RHEL8 and Ubuntu 20.04
In a test environment it does not become visible unless you test if the values are really overwriting config.php because the issue does not break the script.
Reproduction can be done by adding a line with print $CONFIG
or vardump($CONFIG)
which both return NULL when executed via php user.config.php
Research so far:
PHP Docs for json_decode()
Note:
PHP implements a superset of JSON as specified in the original » RFC 7159.
so i tested an object from my user.config.php file in an online validator
There are more RFC's for Json and the validator has to match to 7159 otherwise the validators show it as valid but json_decode()
still returns NULL.
https://jsonformatter.curiousconcept.com/
Finally, the json object that was created as parameter from this role
<?php
/* Ansible managed */
$CONFIG = json_decode('{
"accounts.enable_medial_search": true,
"allow_user_to_change_display_name": true,
"apps_paths": [
{
"path": "/var/www/owncloud/apps",
"url": "/apps",
"writable": false
}
],
"cron_log": true,
"csrf.disabled": false,
"default_language": "de_DE",
"defaultapp": "files",
"enable_avatars": true,
"integrity.ignore.missing.app.signature": [
"theme-example"
],
"knowledgebaseenabled": true,
"log.syslog.format": "[%reqId%][%remoteAddr%][%user%][%app%][%method%][%url%] %message%",
"log_rotate_size": 0,
"log_type": "owncloud",
"logdateformat": "Y-m-d H:i:s.u",
"logfile": "/var/log/owncloud.yml",
"loglevel": 2,
"logtimezone": "Etc/UTC",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.locking": "\\OC\\Memcache\\Redis",
"overwrite.cli.url": "loalhost",
"remember_login_cookie_lifetime": 1296000,
"session_keepalive": true,
"session_lifetime": 86400,
"show_server_hostname": false,
"skeletondirectory": "/var/www/owncloud/core/skeleton",
"syslog_tag": "ownCloud",
"token_auth_enforced": false,
"trusted_domains": [
"localhost",
],
"user.search_min_length": 3,
"version.hide": true
}', true);
Finally I could limit the issue to the following single failure
Invalid character found at position 3. [Code 180, Structure 0]
Stackoverflow is giving some inputs on that.
As a result, when the playbook executes occ install ...
the values from user.config.php are not written into config.php
Please provide the Ansible variales used for the owncloud role.
The faulty part is (invalid comma):
"trusted_domains": [
"localhost",
],
What I'm wondering about is why the JSON converter adds a comma to this list while it does not to e.g. :
"integrity.ignore.missing.app.signature": [
"theme-bwi"
],
Will debug further during this week.
This is the part that we changed.
The customer don't want their internal cluster frontend domains on GitHub.
In the original json object, this was generated as expected.
I'm not able to reproduce it... Using the variable owncloud_trusted_domains
provided by the role to overwrite the default values results in a fully valid JSON object.
Please provide a reproducible example. That means, all owncloud_
variables which results in a malformed JSON object within the user.config.php
file while used together with this Ansible role. The main question is still, what variables have you passed to Ansible to get a faulty JSON object.
The ansible variables are set as following:
owncloud_domain: sub.example.com
owncloud_fqdn: "{{ owncloud_domain }}"
frontend_domains:
- "f1.example.com"
- "f2.example.com"
owncloud_domain_list:
- "{{ owncloud_domain }}"
owncloud_trusted_domains: "{{ owncloud_domain_list + frontend_domains }}"
This results in the follwing user.config.php:
<?php
/* Ansible managed */
$CONFIG = json_decode('{
"accounts.enable_medial_search": true,
"allow_user_to_change_display_name": true,
"apps_paths": [
{
"path": "/var/www/owncloud/apps",
"url": "/apps",
"writable": false
}
],
"cron_log": true,
"csrf.disabled": false,
"default_language": "de_DE",
"defaultapp": "files",
"enable_avatars": true,
"integrity.ignore.missing.app.signature": [
"theme-example"
],
"knowledgebaseenabled": true,
"log.syslog.format": "[%reqId%][%remoteAddr%][%user%][%app%][%method%][%url%] %message%",
"log_rotate_size": 0,
"log_type": "owncloud",
"logdateformat": "Y-m-d H:i:s.u",
"logfile": "/var/log/owncloud.yml",
"loglevel": 2,
"logtimezone": "Etc/UTC",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.local": "\\\\OC\\\\Memcache\\\\APCu",
"memcache.locking": "\\OC\\Memcache\\Redis",
"overwrite.cli.url": "sub.example.com",
"remember_login_cookie_lifetime": 1296000,
"session_keepalive": true,
"session_lifetime": 86400,
"show_server_hostname": false,
"skeletondirectory": "/var/www/owncloud/core/skeleton",
"syslog_tag": "ownCloud",
"token_auth_enforced": false,
"trusted_domains": [
"sub.example.com",
"f1.example.com",
"f2.example.com"
],
"user.search_min_length": 3,
"version.hide": true
}', true);
The function json_decode
returns NULL if this JSON object is given as parameter.
If we dump the variable $CONFIG with var_dump
we can confirm the NULL.
Thanks in advance for your help.
Not reproducible. Related to not supported custom modifications to the role.