Help language development. Donate to The Perl Foundation

UNIX::Privileges cpan:JSTOWE last updated on 2021-01-19
# UNIX::Privileges #

A module for handling UNIX privileges

## Example ##


	use UNIX::Privileges;

	UNIX::Privileges::chown($user, $file);

You can also do

use UNIX::Privileges :ALL;

chown($user, $file);

The `:CH` tag will import `chown` and `chroot` and the `USER` tag will import only `USER`.

Example usage:

	use UNIX::Privileges;

	UNIX::Privileges::chown("nobody", "test.txt");

Example with a chroot:

	use UNIX::Privileges;

	my $user = UNIX::Privileges::userinfo("nobody");
	UNIX::Privileges::chown($user, "/tmp/test.txt");
	# once in the chroot access to the system password file is lost
	# therefore UNIX::Privileges::drop("nobody") will no longer work
	# as the system cannot find the uid or gid of "nobody" anymore
	# fortunately we already have this information in the $user var
	# that we defined above by calling UNIX::Privileges::userinfo
	# just remember you have to do this *before* creating the chroot

## Installation

Assuming ypu have a working Rakudo installation you can install this with *zef* :

    zef install UNIX::Privileges

Some of the tests won't be run unless they are run as 'root', and you
may not be comfortable running a remote installer with escalated
privileges, so you may want to checkout or otherwise download this
package, run the 'root' tests with something like:

    sudo zef test .

(assuming that the Rakudo toolchain is in the global PATH.)

## Support

Please send any suggestions or patches via

## License & Copyright

This is free software, please see the [LICENCE](LICENCE) file in the distribution.

© carlin 2015
© Jonathan Stowe 2017 - 2020