Merge pull request #1261 from McAtte/3.5.x

[3.5.x] fix for #3482 sys.flavor and sys.arch are empty
Tiny optimization in safe_open.

We already know that next_component is neither null nor empty in the
second branch, because of 7f137f0ad5.

(cherry picked from commit e890b4a420a9d7857c8a6a89a5aa5db061045faf)
Fix failure to open paths ending in a slash.

Redmine #3905.

(cherry picked from commit 7fc5a0a65ebe0920b881a338b89482656bafeae6)
Fix incorrect return value for empty string in safe_open.

(cherry picked from commit 7f137f0ad57085a8100bbfa73efd6f06d07678a4)
Update ChangeLog with backported fixes
add acceptance test for #3643
Merge branch '3.5.x' of github.com:cfengine/core into 3.5.x