Jira (BOLT-890) Multi-command bash oneliners don't work with run-as

0 views
Skip to first unread message

Alex Dreyer (JIRA)

unread,
Oct 2, 2018, 4:01:05 PM10/2/18
to puppe...@googlegroups.com
Alex Dreyer created an issue
 
Puppet Task Runner / Task BOLT-890
Multi-command bash oneliners don't work with run-as
Issue Type: Task Task
Assignee: Unassigned
Created: 2018/10/02 1:00 PM
Priority: Normal Normal
Reporter: Alex Dreyer

When a user passes a bash oneliner to run_command with run-as root only the first command is captured by sudo.

In this example false is run as root but /root/foo is run as the connection user.
noformat
bolt command run 'false || touch /root/foo' -n 10.234.3.107 --user centos --run-as root
Started on 10.234.3.107...
Failed on 10.234.3.107:
The command failed with exit code 1
STDERR:
touch: cannot touch ‘/root/foo’: Permission denied
Failed on 1 node: 10.234.3.107
noformat

Workarounds
1. Use multiple calls to run_command
2. Save the oneliner as a script.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Alex Dreyer (JIRA)

unread,
Oct 2, 2018, 4:05:03 PM10/2/18
to puppe...@googlegroups.com
Alex Dreyer updated an issue
Change By: Alex Dreyer
When a user passes a bash oneliner to run_command with run-as root only the first command is captured by sudo.

In this example {{false}} is run as root but {{/root/foo}} is run as the connection user.

{{noformat}}
bolt command run 'false || touch /root/foo' -n 10.234.3.107 --user centos --run-as root
Started on 10.234.3.107...
Failed on 10.234.3.107:
  The command failed with exit code 1
  STDERR:
    touch: cannot touch ‘/root/foo’: Permission denied
Failed on 1 node: 10.234.3.107
{{noformat}}

Workarounds
1. Use multiple calls to run_command Explicitly call the shell {{bolt command run 'sh -c "false || touch /root/foo"'  -n 10.234.3.107 --user centos --run-as root}}

2. Save the oneliner as a script.

Lucy Wyman (JIRA)

unread,
Oct 2, 2018, 4:09:04 PM10/2/18
to puppe...@googlegroups.com
Lucy Wyman updated an issue
Change By: Lucy Wyman
When a user passes a bash oneliner to run_command with run-as root only the first command is captured by sudo.

In this example {{false}} is run as root but {{/root/foo}} is run as the connection user.

{{code}}

bolt command run 'false || touch /root/foo' -n 10.234.3.107 --user centos --run-as root
Started on 10.234.3.107...
Failed on 10.234.3.107:
  The command failed with exit code 1
  STDERR:
    touch: cannot touch ‘/root/foo’: Permission denied
Failed on 1 node: 10.234.3.107

{{code}}

Workarounds
1. Explicitly call the shell {{bolt command run 'sh -c "false || touch /root/foo"'  -n 10.234.3.107 --user centos --run-as root}}


2. Save the oneliner as a script.

Lucy Wyman (JIRA)

unread,
Oct 2, 2018, 4:09:04 PM10/2/18
to puppe...@googlegroups.com
Lucy Wyman updated an issue
When a user passes a bash oneliner to run_command with run-as root only the first command is captured by sudo.

In this example {{false}} is run as root but {{/root/foo}} is run as the connection user.

{{ noformat code }}

bolt command run 'false || touch /root/foo' -n 10.234.3.107 --user centos --run-as root
Started on 10.234.3.107...
Failed on 10.234.3.107:
  The command failed with exit code 1
  STDERR:
    touch: cannot touch ‘/root/foo’: Permission denied
Failed on 1 node: 10.234.3.107
{{ noformat code }}


Workarounds
1. Explicitly call the shell {{bolt command run 'sh -c "false || touch /root/foo"'  -n 10.234.3.107 --user centos --run-as root}}

2. Save the oneliner as a script.

Lucy Wyman (JIRA)

unread,
Oct 2, 2018, 4:09:04 PM10/2/18
to puppe...@googlegroups.com
Lucy Wyman updated an issue
When a user passes a bash oneliner to run_command with run-as root only the first command is captured by sudo.

In this example {{false}} is run as root but {{/root/foo}} is run as the connection user.

{{code}}

bolt command run 'false || touch /root/foo' -n 10.234.3.107 --user centos --run-as root
Started on 10.234.3.107...
Failed on 10.234.3.107:
  The command failed with exit code 1
  STDERR:
    touch: cannot touch ‘/root/foo’: Permission denied
Failed on 1 node: 10.234.3.107

{{code}}


Workarounds
1. Explicitly call the shell {{bolt command run 'sh -c "false || touch /root/foo"'  -n 10.234.3.107 --user centos --run-as root}}

2. Save the oneliner as a script.

Lucy Wyman (JIRA)

unread,
Oct 2, 2018, 4:10:03 PM10/2/18
to puppe...@googlegroups.com

Alex Dreyer (JIRA)

unread,
Oct 2, 2018, 4:19:06 PM10/2/18
to puppe...@googlegroups.com
Alex Dreyer updated an issue
Change By: Alex Dreyer
When a user passes a bash oneliner to run_command with run-as root only the first command is captured by sudo.

In this example {{false}} is run as root but {{/root/foo}} is run as the connection user.

{ code noformat }

bolt command run 'false || touch /root/foo' -n 10.234.3.107 --user centos --run-as root
Started on 10.234.3.107...
Failed on 10.234.3.107:
  The command failed with exit code 1
  STDERR:
    touch: cannot touch ‘/root/foo’: Permission denied
Failed on 1 node: 10.234.3.107
{ code noformat }


Workarounds
1. Explicitly call the shell {{bolt command run 'sh -c "false || touch /root/foo"'  -n 10.234.3.107 --user centos --run-as root}}

2. Save the oneliner as a script.

Yasmin Rajabi (JIRA)

unread,
Aug 15, 2019, 7:20:02 PM8/15/19
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages