fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.15k stars 431 forks source link

Ability to run bash scripts #22627

Open pintomi1989 opened 1 month ago

pintomi1989 commented 1 month ago
noahtalerman commented 1 month ago

@georgekarrv what happens if we don't specify an interpreter in the script? Do we run the script in the host's default shell? Does Fleet always run in bin/sh?

@dherder confirmed that we can upload scripts w/o an interpreter.

dherder commented 1 month ago

@noahtalerman I can confirm that the script will run w/o a declared interpreter.

dherder commented 1 month ago

@noahtalerman the script will run under /bin/sh if there is no shebang. So, with that in mind, why do we not allow for running a bash env?

noahtalerman commented 1 month ago

Moved original issue description here for safekeeping:

Original issue: https://github.com/fleetdm/fleet/issues/21299

Problem

/bin/bash is not currently accepted as a shell interpreter

/bin/sh and /bin/zsh are accepted

Ubuntu machines have bash installed as the default

If a customer has scripts written in bash, they need to rewrite their scripts in either sh or zsh, which is time consuming when there are a large number of scripts in question

Also, there are "bash-isms" that are not POSIX (sh) compatible:

bash to sh problem

What have you tried?

Rewriting scripts in sh or zsh

Potential solutions

Allow /bin/bash as a shell interpreter

What is the expected workflow as a result of your proposal?

Upload scripts to Fleet written in bash, and have them function properly