mirror of
https://github.com/amidaware/tacticalrmm.git
synced 2026-04-26 06:55:52 +03:00
[GH-ISSUE #1732] Bash scripts unable to be run as logged in user #1078
Labels
No labels
In Process
bug
bug
dev-triage
documentation
duplicate
enhancement
fixed
good first issue
help wanted
integration
invalid
pull-request
question
requires agent update
security
ui tweak
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tacticalrmm#1078
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Jan 9, 2024).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/1732
I'm finding some problems with running macOS bash scripts through TRMM.
Updating brew is impossible because it doesn't find the users $PATH
Basically anything that required the user prompt fails unless I'm doing something wrong?
Is there a workaround for this?
@dinger1986 commented on GitHub (Jan 9, 2024):
brew for example is a third party app so could have all sorts of oddities, essentially you need to figure out how to run brew as root. I chatgpt'd it, see below -
When you run the
brewcommand as root, it can't find the$PATHvariable due to the change in the environment variables when switching to the root user. Typically, running Homebrew as root is not recommended because it is designed to work without elevated privileges and running as root can cause various issues, including security risks and permission problems.If you're encountering issues with
brewnot finding the$PATH, here's what you can do:Avoid using root: Run Homebrew with your regular user account. Homebrew is designed to work without needing root access.
Check your
$PATH: Make sure that the$PATHvariable includes the directory where Homebrew is installed, typically/usr/local/binfor macOS. You can check your$PATHby runningecho $PATHin the terminal.Correct permissions: If there are permission issues, you can fix them by running
sudo chown -R $(whoami) /usr/local/*to take ownership of the Homebrew directories. This is safer than running Homebrew as root.Use
sudo -E: If you absolutely must run a command as root and need to preserve the environment variables, you can usesudo -E. However, this is generally not recommended for Homebrew.Remember, running Homebrew as root can lead to security risks and is against its recommended usage. It's best to troubleshoot the issue without resorting to root privileges.
@silversword411 commented on GitHub (Jan 9, 2024):
Also
To run a Bash script as a specific user while you are logged in as root on a Mac, you can use the
sucommand followed by the-coption and the username of the user. Here's the general format:Replace
[username]with the actual username and/path/to/script.shwith the full path to your script. This command switches to the specified user and executes the script in their context.I'm sure we could do some more to try and determine the currently logged in user etc.
A good discussion for the Discord #script channel