releasePrivileges method

  1. @override
void releasePrivileges()
override

On Linux and osx 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.

On Linux and OSX 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 callback.

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');
  });
}

Implementation

@override
void releasePrivileges() {
  throw UnimplementedError();
}