Debian Codegraph @

README

raw
1 NAME
2 Privileges::Drop - A module to make it simple to drop all privileges,
3 even POSIX groups.
4
5 DESCRIPTION
6 This module tries to simplify the process of dropping privileges. This
7 can be useful when your Perl program needs to bind to privileged ports,
8 etc. This module is much like Proc::UID, except that it's implemented in
9 pure Perl. Special care has been taken to also drop saved uid on
10 platforms that support this, currently only test on on Linux.
11
12 SYNOPSIS
13 use Privileges::Drop;
14
15 # Do privileged stuff
16
17 # Drops privileges and sets euid/uid to 1000 and egid/gid to 1000.
18 drop_uidgid(1000, 1000);
19
20 # Drop privileges to user nobody looking up gid and uid with getpwname
21 # This also set the enviroment variables USER, LOGNAME, HOME and SHELL.
22 drop_privileges('nobody');
23
24 METHODS
25 drop_uidgid($uid, $gid, @groups)
26 Drops privileges and sets euid/uid to $uid and egid/gid to $gid.
27
28 Supplementary groups can be set in @groups.
29
30 drop_privileges($user)
31 Drops privileges to the $user, looking up gid and uid with getpwname
32 and calling drop_uidgid() with these arguments.
33
34 The environment variables USER, LOGNAME, HOME and SHELL are also set
35 to the values returned by getpwname.
36
37 Returns the $uid and $gid on success and dies on error.
38
39 NOTE: If drop_privileges() is called when you don't have root
40 privileges it will just return undef;
41
42 NOTES
43 As this module only uses Perl's build in function, it relies on them to
44 work correctly. That means setting $GID and $EGID should also call
45 setgroups(), something that might not have been the case before Perl
46 5.004. So if you are running an older version, Proc::UID might be a
47 better choice.
48
49 AUTHOR
50 Troels Liebe Bentsen <[email protected]>
51
52 COPYRIGHT
53 Copyright(C) 2007-2009 Troels Liebe Bentsen
54
55 This library is free software; you can redistribute it and/or modify it
56 under the same terms as Perl itself.
57