Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Jean Bond updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Jean Bond Labels: resolved-issue-added Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.25205.1579114500448%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Gheorghe Popescu updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Gheorghe Popescu Fix Version/s: FACT 3.14.7 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.24445.1579084920295%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title George Mrejea commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins Jean Bond This ticket modifies existing API by adding an optional parameter, allowing users to use shell builtin commands as first command in custom fact creation. For example, minimal custom fact comprise #!/opt/puppetlabs/puppet/bin/ruby require 'facter' Facter::Core::Execution.execute('first_command parameters && second_command parameters ') By default, puppet expands `first_command` to absolute path, searching first_command in a list of directories. On Linux platform, users can use in place of `first_command` a shell builtin command. Builtin commands are contained within the shell itself, therefore do not have an absolute path. The shell executes the command directly, without invoking another program. By placing {:expand => false}, user change default behaviour and expansion to an absolute path is stopped, and custom fact will execute successfully. ```Facter::Core::Execution.execute('first_command parameters && second_command parameters ', {:expand => false}) ``` If user does not use {:expand => false}, it is equivalent to {:expand => true}, and `first_command` will be expanded to a non existent absolute path, and custom fact will fail. Before users where forced to use as workaround a dummy command 'true' in place of `first_command`. Add Comment
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Jean Bond commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins It's not clear to me how the user should interact with this and how they change this setting. Is it a flag on the command line, a setting in a config file, or something else? Gabriel Nagy, Charlie Sharpsteen? Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.22941.1579024800391%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Dorin Pleava updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Dorin Pleava Fix Version/s: FACT 3.13.5 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.16185.1578494820439%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Dorin Pleava updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Dorin Pleava Fix Version/s: FACT 3.11.11 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.15894.1578470040499%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title George Mrejea updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: George Mrejea Release Notes Summary: Facter::Core::Execution.execute by default searches command passed as argument in a list of directories and expands it to absolute path. Now accepts a new boolean parameter -expand. When true, behaves like before, searches the command and expands it to absolute path. When set to false e.g```Facter::Core::Execution.execute(command, {:expand => false}) ```verifies if it is a shel builtin command, and in that case command is passed as it is (not expanded to absolute path). Release Notes: Enhancement Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Mihai Buzgau updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Mihai Buzgau Sprint: NW - 2019-10-30, NW - 2019-11-13, 2019-11-27 , 2019-12-11 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.47097.1574848264763%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Mihai Buzgau updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Mihai Buzgau Sprint: NW - 2019-10-30, NW - 2019-11-13 , 2019-11-27 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.32074.1573727283319%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Mihai Buzgau updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Mihai Buzgau Sprint: NW - 2019-10-30 , NW - 2019-11-13 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.12229.1572426004616%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Charlie Sharpsteen commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins Adding a boolean option to disable expansion seems reasonable to me. Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.5603.1571930280127%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Thomas Kishel commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins It seems FWIW was worth nothing Oh well! Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.3019.1571848021057%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Gabriel Nagy commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins compgen is bash-specific, so it does not help us here, since leatherman uses sh -c for all shell outs (https://github.com/puppetlabs/leatherman/blob/master/execution/src/posix/execution.cc#L38) Removing the expansion altogether may act weird because of how leatherman searches in the path and how sh inherits environment variables, etc etc. I'm a bit afraid to do that . I agree with adding a configurable option that defaults to the current behavior, and when set to false it does not expand the first argument. Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.2421.1571821980214%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title George Mrejea commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins Thomas Kishel the compgen command is not available on all the platforms, so don't think we can use as a default way to determine the built-in commands. Eg Debian 10: georges-mbp:leatherman george.mrejea$ floaty ssh debian-10-x86_64 The authenticity of host 'kqrazizpal3h2pw.delivery.puppetlabs.net (10.16.127.117)' can't be established. ECDSA key fingerprint is SHA256:vKputyJwe1oct3MvZLSqMDA3wkyWcx/6nrEHoGJWL7c. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'kqrazizpal3h2pw.delivery.puppetlabs.net,10.16.127.117' (ECDSA) to the list of known hosts. Linux kqrazizpal3h2pw 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5 (2019-06-19) x86_64The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@kqrazizpal3h2pw:~# sh -c "compgen -b" sh: 1: compgen: not found
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title George Mrejea assigned an issue to George Mrejea Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: George Mrejea Assignee: George Mrejea Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.68.1571734620139%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Thomas Kishel commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins FWIW: compgen -b lists all the builtins Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.9666.1571680320380%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Charlie Sharpsteen commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins Hmm, if we're executing everything through /usr/bin/sh -c, then what are we gaining by expanding the path to the first argument? Shouldn't the shell be able to handle that by its self? Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.6078.1571347380089%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Gabriel Nagy commented on FACT-2054 Re: Facter::Core::Execution.execute incorrectly expands shell builtins The expansion is done here: https://github.com/puppetlabs/leatherman/blob/master/execution/src/posix/execution.cc#L142 The question is what should we do here? Keep a list of sh builtins which we should check against when expanding the first argument? Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.4943.1571314020094%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Mihai Buzgau updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Mihai Buzgau Sprint: PR NW - Triage 2019-10-30 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.2424.1571216220185%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Mihai Buzgau updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Mihai Buzgau Story Points: 5 Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.2422.1571216220176%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Mihai Buzgau updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Mihai Buzgau Sprint: PR - Triage Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.133598.1570538940215%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Charlie Sharpsteen updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Charlie Sharpsteen Team: Night's Watch Add Comment This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.327886.1570111406000.127523.1570111680091%40Atlassian.JIRA.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Charlie Sharpsteen updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Charlie Sharpsteen When executing commands, Facter will expand the first word in the command string to be a fully qualified path. I.e. {{ls -l}} will become {{/usr/bin/ls -l}}. If the command string is a compound command that contains a pipeline or looping conditional construct, then Facter will wrap the executing string in {{/ usr/ bin/sh -c}}.However, the first word of the compound is still expanded to an absolute path. This breaks shell builtins like {{cd}} as they are expanded to external commands like {{/usr/bin/cd}} or fail to be found on the PATH.h2. Reproduction Case- Install the latest version of {{puppet-agent}} on CentOS 7, along with strace:{code:bash}yum install -y http://yum.puppetlabs.com/puppet-release-el-7.noarch.rpmyum install -y puppet-agent strace{code}- Create a test script that loads Facter, and uses it to execute a compound command that begins with {{cd}}:{code:bash}cat < test.rb#!/opt/puppetlabs/puppet/bin/rubyrequire 'facter'puts Facter::Core::Execution.execute('cd /opt/puppetlabs && ls')EOFchmod +x test.rb{code} - Execute the test script.h3. OutcomeThe script prints the contents of the current working directory instead of {{/opt/puppetlabs}}:{noformat}# ./test.rb1anaconda-ks.cfglinux.isotest.rb{noformat}Running the script under strrace reveals that {{cd}} is being expanded to {{/usr/bin/cd}} before being passed to {{sh -c}}:{noformat}# strace -f -e trace=execve ./test.rbexecve("./test.rb", ["./test.rb"], [/* 23 vars */]) = 0strace: Process 20373 attachedstrace: Process 20374 attached[pid 20374] execve("/usr/bin/sh", ["sh", "-c", "/usr/bin/cd /opt/puppetlabs && l"...], [/* 24 vars */]) = 0strace: Process 20375 attached[pid 20375] execve("/usr/bin/cd", ["/usr/bin/cd", "/opt/puppetlabs"], [/* 24 vars */]) = 0[pid 20375] +++ exited with 0 +++[pid 20374] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20375, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---strace: Process 20376 attached[pid 20376] execve("/usr/bin/ls", ["ls"], [/* 24 vars */]) = 0[pid 20376] +++ exited with 0 +++[pid 20374] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20376, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---[pid 20374] +++ exited with 0 +++[pid 20372] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20374, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---1anaconda-ks.cfglinux.isotest.rb[pid 20373] +++ exited with 0 ++ exited with 0 +++{noformat}h3. Expected OutcomeThe script prints the content of {{/opt/puppetlabs}}:{noformat}# ./test.rbbinfacterpuppetpxp-agent{noformat}h3. Suggested WorkaroundThe expansion only affects the first word in the command line, so adding an extra {{true &&}} to the compound command acts as a sacrificial noop that takes the hit instead.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Charlie Sharpsteen updated an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Change By: Charlie Sharpsteen When executing commands, Facter will expand the first word in the command string to be a fully qualified path. I.e. {{ls -l}} will become {{/usr/bin/ls -l}}. If the command string is a compound command that contains a pipeline or looping construct, then Facter will wrap the executing in {{/bin/sh -c}}.However, the first word of the compound is still expanded to an absolute path. This breaks shell builtins like {{cd}} as they are expanded to external commands like {{/usr/bin/cd}} or fail to be found on the PATH.h2. Reproduction Case- Install the latest version of {{puppet-agent}} on CentOS 7, along with strace:{code:bash}yum install -y http://yum.puppetlabs.com/puppet-release-el-7.noarch.rpmyum install -y puppet-agent strace{code}- Create a test script that loads Facter, and uses it to execute a compound command that begins with {{cd}}:{code:bash}cat < test.rb#!/opt/puppetlabs/puppet/bin/rubyrequire 'facter'puts Facter::Core::Execution.execute('cd /opt/puppetlabs && ls')EOFchmod +x test.rb{code} - Execute the test scrip script .h3. OutcomeThe script prints the contents of the current working directory instead of {{/opt/puppetlabs}}:{noformat}# ./test.rb1anaconda-ks.cfglinux.isotest.rb{noformat}Running the script under strrace reveals that {{cd}} is being expanded to {{/usr/bin/cd}} before being passed to {{sh -c}}:{noformat}# strace -f -e trace=execve ./test.rbexecve("./test.rb", ["./test.rb"], [/* 23 vars */]) = 0strace: Process 20373 attachedstrace: Process 20374 attached[pid 20374] execve("/usr/bin/sh", ["sh", "-c", "/usr/bin/cd /opt/puppetlabs && l"...], [/* 24 vars */]) = 0strace: Process 20375 attached[pid 20375] execve("/usr/bin/cd", ["/usr/bin/cd", "/opt/puppetlabs"], [/* 24 vars */]) = 0[pid 20375] +++ exited with 0 +++[pid 20374] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20375, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---strace: Process 20376 attached[pid 20376] execve("/usr/bin/ls", ["ls"], [/* 24 vars */]) = 0[pid 20376] +++ exited with 0 +++[pid 20374] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20376, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---[pid 20374] +++ exited with 0 +++[pid 20372] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20374, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---1anaconda-ks.cfglinux.isotest.rb[pid 20373] +++ exited with 0 ++ exited with 0 +++{noformat}h3. Expected OutcomeThe script prints the content of {{/opt/puppetlabs}}:{noformat}# ./test.rbbinfacterpuppetpxp-agent{noformat}h3. Suggested WorkaroundThe expansion only affects the first word in the command line, so adding an extra {{true &&}} to the compound command acts as a sacrificial noop that takes the hit instead.
Jira (FACT-2054) Facter::Core::Execution.execute incorrectly expands shell builtins
Title: Message Title Charlie Sharpsteen created an issue Facter / FACT-2054 Facter::Core::Execution.execute incorrectly expands shell builtins Issue Type: Bug Assignee: Unassigned Created: 2019/10/03 7:03 AM Priority: Normal Reporter: Charlie Sharpsteen When executing commands, Facter will expand the first word in the command string to be a fully qualified path. I.e. ls -l will become /usr/bin/ls -l. If the command string is a compound command that contains a pipeline or looping construct, then Facter will wrap the executing in /bin/sh -c. However, the first word of the compound is still expanded to an absolute path. This breaks shell builtins like cd as they are expanded to external commands like /usr/bin/cd or fail to be found on the PATH. Reproduction Case Install the latest version of puppet-agent on CentOS 7, along with strace: yum install -y http://yum.puppetlabs.com/puppet-release-el-7.noarch.rpm yum install -y puppet-agent strace Create a test script that loads Facter, and uses it to execute a compound command that begins with cd: