Jira (PUP-5704) The "posix" provider of the "exec" resource seems to invoke a shell even though the documentation says it doesn't

2 views
Skip to first unread message

Alexander Kurtz (JIRA)

unread,
Jan 12, 2016, 7:47:03 AM1/12/16
to puppe...@googlegroups.com
Alexander Kurtz created an issue
 
Puppet / Bug PUP-5704
The "posix" provider of the "exec" resource seems to invoke a shell even though the documentation says it doesn't
Issue Type: Bug Bug
Affects Versions: PUP 3.8.4
Assignee: Unassigned
Created: 2016/01/12 4:46 AM
Environment:

Debian Testing (stretch) with Puppet 3.8.4

Priority: Normal Normal
Reporter: Alexander Kurtz

This issue was first reported here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809786

Hi,

the puppet type reference describes the "posix" provider of the "exec"
resource like this: [0]

posix
Executes external binaries directly, without passing through a shell or
performing any interpolation. This is a safer and more predictable way to
execute most commands, but prevents the use of globbing and shell built-ins
(including control logic like “for” and “if” statements).

However:

  1. cat manifest.pp
    $input = 'foo; if false; then exit 23; else exit 42; fi'

exec { "/bin/echo $

{input}

":
provider => 'posix',
}

  1. puppet apply manifest.pp
    Notice: Compiled catalog for shepard.kurtz.be in environment production in 0.04 seconds
    Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
    Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
    Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
    Notice: Finished catalog run in 0.08 seconds

I'm not really sure what to make of this, but it seems... unexpected.
What do you guys think?

Best regards

Alexander Kurtz

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Atlassian logo

Alexander Kurtz (JIRA)

unread,
Jan 12, 2016, 7:49:04 AM1/12/16
to puppe...@googlegroups.com
Alexander Kurtz updated an issue


Hi,

the puppet type reference describes the "posix" provider of the "exec"
resource like this: [0]

posix
Executes external binaries directly, without passing through a shell or
performing any interpolation. This is a safer and more predictable way to
execute most commands, but prevents the use of globbing and shell built-ins
(including control logic like “for” and “if” statements).

However:

# cat manifest.pp 

$input = 'foo; if false; then exit 23; else exit 42; fi'
exec { "/bin/echo ${input}":
provider => 'posix',
}
# puppet apply manifest.pp 

Notice: Compiled catalog for shepard.kurtz.be in environment production in 0.04 seconds
Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Notice: Finished catalog run in 0.08 seconds


I'm not really sure what to make of this, but it seems... unexpected.
What do you guys think?

Best regards

Alexander Kurtz

Alexander Kurtz (JIRA)

unread,
Jan 12, 2016, 7:55:03 AM1/12/16
to puppe...@googlegroups.com
Alexander Kurtz updated an issue
This issue was first reported here: [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809786 |https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809786 ]

Hi,

the puppet type reference describes the "posix" provider of the "exec"
resource like this: [0]

posix
Executes external binaries directly, without passing through a shell or
performing any interpolation. This is a safer and more predictable way to
execute most commands, but prevents the use of globbing and shell built-ins
(including control logic like “for” and “if” statements).

However:

root@shepard:~ # cat manifest.pp 

$input = 'foo; if false; then exit 23; else exit 42; fi'
exec { "/bin/echo ${input}":
provider => 'posix',
}
root@shepard:~ # puppet apply manifest.pp 

Notice: Compiled catalog for shepard.kurtz.be in environment production in 0.04 seconds
Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Notice: Finished catalog run in 0.08 seconds
root@shepard:~


I'm not really sure what to make of this, but it seems... unexpected.
What do you guys think?

Best regards

Alexander Kurtz

Markus Frosch (JIRA)

unread,
Jan 12, 2016, 8:02:27 AM1/12/16
to puppe...@googlegroups.com

Alexander Kurtz (JIRA)

unread,
Jun 13, 2016, 12:04:03 PM6/13/16
to puppe...@googlegroups.com

This still happens with Puppet 4.5.0:

{{root@shepard:~# puppet --version
4.5.0
root@shepard:~# cat manifest.pp

$input = 'foo; if false; then exit 23; else exit 42; fi'

exec { "/bin/echo $

{input}

":
provider => 'posix',
}
root@shepard:~# puppet apply manifest.pp
Notice: Compiled catalog for shepard in environment production in 0.08 seconds


Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]

Notice: Applied catalog in 0.05 seconds
root@shepard:~#}}

This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Alexander Kurtz (JIRA)

unread,
Jun 13, 2016, 12:04:03 PM6/13/16
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Jun 13, 2016, 12:14:02 PM6/13/16
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jun 13, 2016, 12:40:03 PM6/13/16
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
This issue was first reported here: [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809786]


Hi,

the puppet type reference describes the "posix" provider of the "exec"
resource like this: [0]

posix
Executes external binaries directly, without passing through a shell or
performing any interpolation. This is a safer and more predictable way to
execute most commands, but prevents the use of globbing and shell built-ins
(including control logic like “for” and “if” statements).

However:

{noformat}
root@shepard:~# cat manifest.pp 
$input = 'foo; if false; then exit 23; else exit 42; fi'
exec { "/bin/echo ${input}":
provider => 'posix',
}
root@shepard:~# puppet apply manifest.pp 
Notice: Compiled catalog for shepard.kurtz.be in environment production in 0.04 seconds

Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Notice: Finished catalog run in 0.08 seconds
root@shepard:~# 
{noformat}

I'm not really sure what to make of this, but it seems... unexpected.
What do you guys think?

Best regards

Alexander Kurtz

[0] [https://docs.puppetlabs.com/references/3.8.latest/type.html#exec-provider-posix]

Alexander Kurtz (JIRA)

unread,
Nov 9, 2016, 8:50:05 AM11/9/16
to puppe...@googlegroups.com
Alexander Kurtz updated an issue
Change By: Alexander Kurtz
Affects Version/s: PUP 4.8.0
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Alexander Kurtz (JIRA)

unread,
Nov 9, 2016, 8:50:07 AM11/9/16
to puppe...@googlegroups.com
 
Re: The "posix" provider of the "exec" resource seems to invoke a shell even though the documentation says it doesn't

Still happens with Puppet 4.8.0:

{{
root@shepard:~# puppet --version
4.8.0


root@shepard:~# cat manifest.pp
$input = 'foo; if false; then exit 23; else exit 42; fi'

exec { "/bin/echo $

{input}

":
provider => 'posix',
}
root@shepard:~# puppet apply manifest.pp

Notice: Compiled catalog for shepard.informatik.tu-muenchen.de in environment production in 0.17 seconds


Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]

Notice: Applied catalog in 0.05 seconds
root@shepard:~#
}}

Alexander Kurtz (JIRA)

unread,
Mar 22, 2017, 10:04:02 AM3/22/17
to puppe...@googlegroups.com

Still happens with Puppet 4.8.2:

root@shepard:~# puppet --version
4.8.2


root@shepard:~# cat manifest.pp
$input = 'foo; if false; then exit 23; else exit 42; fi'

exec { "/bin/echo $

{input}

":
provider => 'posix',
}
root@shepard:~# puppet apply manifest.pp

Notice: Compiled catalog for shepard in environment production in 0.17 seconds


Notice: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: foo
Error: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]
Error: /Stage[main]/Main/Exec[/bin/echo foo; if false; then exit 23; else exit 42; fi]/returns: change from notrun to 0 failed: /bin/echo foo; if false; then exit 23; else exit 42; fi returned 42 instead of one of [0]

Notice: Applied catalog in 0.09 seconds
root@shepard:~#

Alexander Kurtz (JIRA)

unread,
Mar 22, 2017, 10:04:02 AM3/22/17
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
May 16, 2017, 1:13:02 PM5/16/17
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 21, 2022, 1:14:03 PM6/21/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Security: Confidential
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages