crossplane-contrib / provider-cloudinit

Crossplane provider for Cloud-init templating
Apache License 2.0
12 stars 1 forks source link

ConfigMap loaded with carriage-return (\r) #7

Closed displague closed 3 years ago

displague commented 3 years ago

Carriage-return is not valid in the first line of shebang scripts.

Configmaps read in through parts include carriage-returns.

If this is not a bug, provide documentation that shows how to ingest a shebang script as a confimap part.

displague commented 3 years ago

This depends on the configmap:

The following 'works':

apiVersion: v1
kind: ConfigMap
metadata:
  name: foo
  namespace: default
data:
  foo: |
    #!/bin/sh
    echo Hey There
"Content-Type: multipart/mixed; boundary=\"MIMEBOUNDARY\"\nMIME-Version:
    1.0\r\n\r\n--MIMEBOUNDARY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type:
    text/x-shellscript\r\nMime-Version: 1.0\r\n\r\n#!/bin/sh\necho Hey There\n\r\n--MIMEBOUNDARY

However, this does not "work":

apiVersion: v1
kind: ConfigMap
metadata:
  name: foo
  namespace: default
data:
  foo: "#!/bin/sh"

The configmap data renders as:

"Content-Type: multipart/mixed; boundary=\"MIMEBOUNDARY\"\nMIME-Version:
    1.0\r\n\r\n--MIMEBOUNDARY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type:
    text/x-shellscript\r\nMime-Version: 1.0\r\n\r\n#!/bin/sh\r\n--MIMEBOUNDARY

https://groups.google.com/g/comp.lang.python/c/w5dYWUDHLvY/m/6S_bFnouzzMJ - \r is not known to the kernel (of various OSes), so shebangs validators (such as https://github.com/packethost/userdata-rb/blob/master/lib/cloudinit_userdata/formats/shell_script.rb#L7) should not accept them.

displague commented 3 years ago

Closing this as will not fix. Include a newline as a work-around.