Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STPrivilegedTask not working when invoking bash #97

Closed
sveinbjornt opened this issue May 10, 2017 · 7 comments
Closed

STPrivilegedTask not working when invoking bash #97

sveinbjornt opened this issue May 10, 2017 · 7 comments

Comments

@sveinbjornt
Copy link
Owner

STPrivilegedTask works if interpreter is /bin/sh but not /bin/bash.

But it seems that with a script written in bash, platypus doesn’t run the script with root privileges.

We had a script, written in sh, which has the root level, everything’s fine in Platypus.

We wanted to do do the same with a script written in bash. But we have seen that in Platypus, the script has the right of the user, not the rights of root.

Is it normal?

@enarmontas
Copy link

enarmontas commented Mar 14, 2018

I ran in to this issue. Some of the scripts we need to run are written in bash and I noticed that Platypus fails on those scripts.

Is there any plans to fix that?

Currently as a workaround I wrote another script that removes bashisms from /bin/bash script so I can run it as /bin/sh.

@sveinbjornt
Copy link
Owner Author

Truth be told, I have no idea what's causing this. /bin/sh is a bash binary (bash being the default shell on macOS), but it's different from /bin/bash. Why? Your guess is as good as mine.

See the following:

screen shot 2018-03-15 at 18 19 26

@hstriepe
Copy link

hstriepe commented Apr 7, 2018

I can confirm, reliable failure with /bin/bash, but also intermittent failure with /bin/sh.
Cost me 4 hours today because I presumed it to be my fault.

@hstriepe
Copy link

hstriepe commented Apr 7, 2018

Just checked to make sure, this is not an issue with the OS. At least sh & bash have not changed since El Capitan. -v3.2.57

@hstriepe
Copy link

hstriepe commented Apr 7, 2018

Ok, found the following:

  1. Changing the scripts to sh fixed the issue
  2. Minor errors unnoticed in running from shell (e.g. the script continues) seems to abort the script in Platypus. You need to do verbose checking and error trapping to track this down

#! /bin/bash clearly cannot run as root.

@mirkop
Copy link

mirkop commented Jan 19, 2021

I know that this is an old issue, but it would help note this known issue in the documentation.

Special Options

Run with root privileges: If selected, the application prompts for an Administrator password and executes the script with escalated privileges via Apple's Security Framework. This is not strictly equivalent to running the script as the root user. For details, see the documentation for Apple's Security Framework.

Platypus scripts must not use the 'sudo' command. This causes the script to prompt for input via STDIN, and since no input is forthcoming, the application will hang indefinitely.

Please note that if this option is selected, the script will not print STDERR output due to limitations in the Security APIs. This can be circumvented by using a shell script to execute another script while piping STDERR into STDOUT (e.g. perl myScript.pl 2>&1).

Known issue: /bin/bash scripts cannot run with root privileges.

@sveinbjornt
Copy link
Owner Author

@mirkop Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants