Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Fix FreeBSD's 'echo' lack of -e option and 'base64' utility #137

Closed

Conversation

SamuAlfageme
Copy link

  • FreeBSD's 'echo' does not happen to have -e option - this caused the START_SCRIPT_BASE64 decoding step to result in an empty 'one-start-script'. And therefore it's replaced with the printf builtin (see ref. https://stackoverflow.com/a/10576796/2172072)
[root@freebsd]/root: echo -en "VGhpcyBpcyBiYXNlNjQ="
-en VGhpcyBpcyBiYXNlNjQ=
  • Also, in FreeBSD 9.3 'base64' was removed from the default installation; this reverts 16d375d
[root@freebsd]/root: freebsd-version
11.1-RELEASE-p4
[root@freebsd]/root: base64
base64: Command not found.

- FreeBSD's 'echo' does not happen to have -e option - this caused the
  START_SCRIPT_BASE64 decoding step to result in an empty 'one-start-script'.
  Therefore it's replaced with 'printf' builtin
  (see ref. https://stackoverflow.com/a/10576796/2172072)
- Also, in FreeBSD 9.3 'base64' was removed from the default installation,
  this reverts OpenNebula@16d375d#diff-8415297a085e6d70ff6310959532593a
- This can be considered part of OpenNebula#131
@vholer
Copy link
Contributor

vholer commented Feb 4, 2019

Hello @SamuAlfageme , thanks for the comments:

  • All the scripts are expected to use bash, no other shell for now. And, echo -en should be working even with bash on FreeBSD:
root@freebsd:~ # echo -en "VGhpcyBpcyBiYXNlNjQ="
-en VGhpcyBpcyBiYXNlNjQ=
root@freebsd:~ # bash
[root@freebsd ~]# echo -en "VGhpcyBpcyBiYXNlNjQ="
VGhpcyBpcyBiYXNlNjQ=[root@freebsd ~]# 

The question is more if we need -e here.

  • Contextualization package has following dependencies sudo bash curl base64 ruby open-vm-tools-nox11, which are now expected to be installed manually (FPM packager doesn't handle package dependencies properly). In the Linux world, base64 is part of base system (GNU coreutils), but openssl doesn't have to be. That's why those few uses of openssl were removed.

vholer pushed a commit that referenced this pull request Nov 14, 2019
@vholer
Copy link
Contributor

vholer commented Nov 14, 2019

Although the echo shouldn't be an issue, I have changed it from echo -en to just better portable echo. Proposed change with printf isn't really the same. Although, currently it doesn't make much sense to expand backslashes in the base64 (machine) encoded string, but do that for base raw string. It leads to inconsistent treating of final start script content.

For now I have changed just to echo by 53ee309, we'll see if there was some real use of this feature.

Leaving base64 as is.

@vholer vholer closed this Nov 14, 2019
@SamuAlfageme
Copy link
Author

@vholer sorry I missed the notification on your first comment - you're absolutely right about the dependencies. Back then I was using a custom, pretty minimal FreeBSD distro (pfSense) that doesn't come with base64 bundled.

Maybe I can try 53ee309 in a couple of days. Will keep you posted. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants