releasePrivileges abstract method
On Linux and MacOS systems makes the script run as a non-privileged user even when started with sudo.
This method is used to overcome issues when running as sudo where the script would change the ownership to root:root for any created/modified file.
This method is normally called as the first line of your main() method.
Calling this method on Windows is unnecessary but harmless.
Calling this method for a non-privileged user has no affect.
On Linux and MacOS releasing privileges sets the uid and gid to the user's original privileges so any files that are created/modified get the original user's uid/gid.
You should use this method in conjuctions with withPrivileges so that only specific parts of your code run with privileges.
You must NEVER call releasePrivileges within a withPrivileges action.
void main(){
/// downgrade script to not run as sudo
Shell.current.releasePrivileges();
/// ... do some non-sudo things
/// any code within the following code block will be run
/// with sudo privileges.
Shell.current.withPrivileges(() {
copyTree('\etc\keys', '\some\insecure\location');
});
}
See:
Implementation
void releasePrivileges();