|
Gin
|
Keeps one elevated worker process alive so the admin password prompt is only shown once per app run, rather than once per operation. More...
#include <gin_elevatedfilecopy.h>
Public Member Functions | |
| ElevatedSession ()=default | |
| ~ElevatedSession () | |
| ElevatedFileCopy::Result | start () |
| Starts the worker, prompting for admin access if it isn't already running. | |
| bool | isRunning () |
| True if the worker is running. | |
| ElevatedFileCopy::Result | runScript (const juce::String &contents) |
| Runs the contents of a shell script (macOS) or batch file (Windows) as root/admin, starting the worker if required. | |
| void | stop () |
| Shuts the worker down. | |
Static Public Member Functions | |
| static bool | processCommandLine (juce::String commandLine) |
| Call from JUCEApplication::initialise() and abort the initialise process if returns true. | |
Keeps one elevated worker process alive so the admin password prompt is only shown once per app run, rather than once per operation.
On macOS the worker is a /bin/sh command loop started with AuthorizationExecuteWithPrivileges; the only way to reach it is the private pipe inherited from this process. On Windows the app is relaunched elevated (a single UAC prompt) and talked to over a named pipe guarded by a random token; call processCommandLine from your app's initialise and return asap if it returns true, as that instance is the worker.
Scripts are sent by content, not path, and the worker writes them to a location only it can modify, so nothing runs as root from a world writable location.
|
default |
| ElevatedSession::~ElevatedSession | ( | ) |
| ElevatedFileCopy::Result ElevatedSession::start | ( | ) |
Starts the worker, prompting for admin access if it isn't already running.
Called automatically by runScript
| bool ElevatedSession::isRunning | ( | ) |
True if the worker is running.
| ElevatedFileCopy::Result ElevatedSession::runScript | ( | const juce::String & | contents | ) |
Runs the contents of a shell script (macOS) or batch file (Windows) as root/admin, starting the worker if required.
Blocks until the script has finished. The script's output is discarded, so redirect anything needed to a file
| void ElevatedSession::stop | ( | ) |
Shuts the worker down.
The next runScript prompts again. Also called by the destructor, and the worker exits by itself if this process dies with the session still open
Call from JUCEApplication::initialise() and abort the initialise process if returns true.