Bug #7094
closedAgent processes parts of the environment (multiline bash variables)
Description
First:
Don't blame me. It's Linux. It's icky and you need to wash.
@# rudder agent run R: @@Common@@log_info@@hasPolicyServer-root@@common-root@@146@@common@@StartRun@@2015-08-11 22:17:58+00:00##55c91479-8d2e-4f57-97ea-7d5203c78fe3@#Start execution with config [1600061809] 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :DO]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :cd]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :do]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :le]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :li#62:co#157:am:xn:xv:LP:sr]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :cs]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :im]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :ke]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :ti]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :se]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :Co#8:pa#64:AF]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an i llegal character ' ' in class/variable identifier 'node.env[ :vb]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :ac]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :po]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :k4]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :k9]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :F4]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :F8]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :kB]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :#2]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :%i]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :kN]'. 2015-08-12T00:17:59+0200 error: /default/get_environment_variables/commands/'/var/rudder/cfengine-community/module/env'[0]: Module protocol contained an illegal character ' ' in class/variable identifier 'node.env[ :kr]'. 2015-08-12T00:18:08+0200 notice: /default/check_sudo_parameters/commands/'/usr/sbin/visudo'[0]: Q: "...bin/visudo -c ": /etc/sudoers.rudder: parsed OK@
So what happens and why, looking at env we find the problem:
@root@install ~]# env MANPATH=/opt/rudder/share/man:/opt/rudder/share/man HOSTNAME=install SHELL=/bin/bash TERM=xterm HISTSIZE=1000 USER=root LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36: TERMCAP=SC|xterm|VT 100/ANSI X3.64 virtual terminal:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\ :cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\ :do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\ :le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\ :li#62:co#157:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\ :cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:\ :im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:\ :ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\ :ti=\E[?1049h:te=\E[?1049l:us=\E[4m:ue=\E[24m:so=\E[3m:\ :se=\E[23m:mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:ms:\ :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\ :vb=\Eg:G0:as=\E(0:ae=\E(B:\ :ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\ :po=\E[5i:pf=\E[4i:k0=\E[10~:k1=\EOP:k2=\EOQ:k3=\EOR:\ :k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:\ :k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:F3=\E[1;2P:\ :F4=\E[1;2Q:F5=\E[1;2R:F6=\E[1;2S:F7=\E[15;2~:\ :F8=\E[17;2~:F9=\E[18;2~:FA=\E[19;2~:kb=:K2=\EOE:\ :kB=\E[Z:kF=\E[1;2B:kR=\E[1;2A:*4=\E[3;2~:*7=\E[1;2F:\ :#2=\E[1;2H:#3=\E[2;2~:#4=\E[1;2D:%c=\E[6;2~:%e=\E[5;2~:\ :%i=\E[1;2C:kh=\E[1~:@1=\E[1~:kH=\E[4~:@7=\E[4~:\ :kN=\E[6~:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:kd=\EOB:\ :kr=\EOC:kl=\EOD:km: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/rudder/cfengine-community/bin:/root/bin:/var/rudder/cfengine-community/bin:/root/bin MAIL=/var/spool/mail/root STY=15484.pts-0.install PWD=/root LANG=en_US.UTF-8 HISTCONTROL=ignoredups HOME=/root SHLVL=2 LOGNAME=root CVS_RSH=ssh WINDOW=0 LESSOPEN=||/usr/bin/lesspipe.sh %s G_BROKEN_FILENAMES=1 _=/bin/env @
It's TERMCAP!
No idea guys, really.
But since this seems to be "legal" it should not blow stuff up. The messages from Rudder, being red, look horrible.
Updated by Florian Heigl over 9 years ago
Oh and this was indented, it's just redmine that didn't like what I pasted.
[root@install ~]# env MANPATH=/opt/rudder/share/man:/opt/rudder/share/man HOSTNAME=install SHELL=/bin/bash TERM=xterm HISTSIZE=1000 USER=root LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36: TERMCAP=SC|xterm|VT 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 :%i=\E[1;2C:kh=\E[1~:@1=\E[1~:kH=\E[4~:@7=\E[4~:\ :kN=\E[6~:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:kd=\EOB:\ :kr=\EOC:kl=\EOD:km: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/rudder/cfengine-community/bin:/root/bin:/var/rudder/cfengine-community/bin:/root/bin MAIL=/var/spool/mail/root STY=15484.pts-0.install
set on the other hand gives a single line.
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' PS1='[\u@\h \W]\$ ' PS2='> ' PS4='+ ' PWD=/root SHELL=/bin/bash SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor SHLVL=2 STY=15484.pts-0.install TERM=xterm TERMCAP=$'SC|xterm|VT 100/ANSI X3.64 virtual terminal:\\\n\t:DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:UP=\\E[%dA:bs:bt=\\E[Z:\\\n\t:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:ct=\\E[3g:\\\n\t:do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:\\\n\t:le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:\\\n\t:li#62:co#157:am:xn:xv:LP:sr=\\EM:al=\\E[L:AL=\\E[%dL:\\\n\t:cs=\\E[%i%d;%dr:dl=\\E[M:DL=\\E[%dM:dc=\\E[P:DC=\\E[%dP:\\\n\t:im=\\E[4h:ei=\\E[4l:mi:IC=\\E[%d@:ks=\\E[?1h\\E=:\\\n\t:ke=\\E[?1l\\E>:vi=\\E[?25l:ve=\\E[34h\\E[?25h:vs=\\E[34l:\\\n\t:ti=\\E[?1049h:te=\\E[?1049l:us=\\E[4m:ue=\\E[24m:so=\\E[3m:\\\n\t:se=\\E[23m:mb=\\E[5m:md=\\E[1m:mr=\\E[7m:me=\\E[m:ms:\\\n\t:Co#8:pa#64:AF=\\E[3%dm:AB=\\E[4%dm:op=\\E[39;49m:AX:\\\n\t:vb=\\Eg:G0:as=\\E(0:ae=\\E(B:\\\n\t:ac=\\140\\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\\\n\t:po=\\E[5i:pf=\\E[4i:k0=\\E[10~:k1=\\EOP:k2=\\EOQ:k3=\\EOR:\\\n\t:k4=\\EOS:k5=\\E[15~:k6=\\E[17~:k7=\\E[18~:k8=\\E[19~:\\\n\t:k9=\\E[20~:k;=\\E[21~:F1=\\E[23~:F2=\\E[24~:F3=\\E[1;2P:\\\n\t:F4=\\E[1;2Q:F5=\\E[1;2R:F6=\\E[1;2S:F7=\\E[15;2~:\\\n\t:F8=\\E[17;2~:F9=\\E[18;2~:FA=\\E[19;2~:kb=\177:K2=\\EOE:\\\n\t:kB=\\E[Z:kF=\\E[1;2B:kR=\\E[1;2A:*4=\\E[3;2~:*7=\\E[1;2F:\\\n\t:#2=\\E[1;2H:#3=\\E[2;2~:#4=\\E[1;2D:%c=\\E[6;2~:%e=\\E[5;2~:\\\n\t:%i=\\E[1;2C:kh=\\E[1~:@1=\\E[1~:kH=\\E[4~:@7=\\E[4~:\\\n\t:kN=\\E[6~:kP=\\E[5~:kI=\\E[2~:kD=\\E[3~:ku=\\EOA:kd=\\EOB:\\\n\t:kr=\\EOC:kl=\\EOD:km:' UID=0 USER=root WINDOW=0 _=env colors=/etc/DIR_COLORS
...etc etc...
Updated by Janos Mattyasovszky about 9 years ago
This would work on Linux, where env supports the -0 option:
env -0 | sed 's/"/\\"/g; s/\x0/"\n/g;' | sed 's/^\([^= \t]\+\)=/node.env[\1]="/g;'
(tested on Fedora 21)
Updated by Janos Mattyasovszky about 9 years ago
- Target version set to 3.1.5
- Pull Request set to https://github.com/Normation/rudder-techniques/pull/771
- How to reproduce updated (diff)
- Found in version(s) old 3.1.2 added
Please check PR @ https://github.com/Normation/rudder-techniques/pull/771.
Changed the way it parses the environment:
Instead of writing a bash script, that is being executed as a module (which apparently also does not handle multi-lined strings), the output of env -0 (null-terminated) is used, and by grepping/sed/tr-ing, we extract the variable names to an array, then populate the node.env by the getenv() built-in function, which was introduced in 3.0.4, and are happy.
I have not found a way to reproduct something similar on Solaris, I was looking into the bash's "set", which outputs all variables in ANSI-C-Like quoting, but not only the environment variables, so this might need additional processing, probably by something like printenv...
Updated by Janos Mattyasovszky about 9 years ago
- Assignee set to Nicolas CHARLES
Updated by Jonathan CLARKE about 9 years ago
- Related to User story #5643: Implement node variable acces via ${node.env[ENV]} added
Updated by Jonathan CLARKE about 9 years ago
- Status changed from New to Pending technical review
- Target version changed from 3.1.5 to 3.0.12
This was introduced in Rudder 3.0, so should be fixed there too.
Updated by Janos Mattyasovszky about 9 years ago
- Status changed from Pending technical review to Pending release
- % Done changed from 0 to 100
Applied in changeset rudder-techniques|86b088c2ed9d23fad961a9f66c9e7f8fe7d10d71.
Updated by Jonathan CLARKE about 9 years ago
Applied in changeset rudder-techniques|ff9d4db4671c6e00dfcf152cd764b85e73a2eeb6.
Updated by Vincent MEMBRÉ about 9 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 3.0.12 and 3.1.5 which were released today.
- 3.0: Announce Changelog
- 3.1: Announce Changelog
- Download: https://www.rudder-project.org/site/get-rudder/downloads/
Updated by Alexis Mousset almost 9 years ago
- Related to Bug #7761: Error in environment-variables.cf on Centos 5 added
Updated by Janos Mattyasovszky over 8 years ago
- Related to Architecture #8464: Make environment variables parse easier added
Updated by Benoît PECCATTE almost 8 years ago
- Found in version(s) old deleted (
3.1.2)
Updated by Nicolas CHARLES about 7 years ago
- Related to Bug #11435: Error message on classical windows agent when getting environement variable added