SetID(3) User Contributed Perl Documentation SetID(3)NAMENOCpulse::SetID - Set user and group IDs and revert
SYNOPSIS
use NOCpulse::SetID;
# Create a new identity
my $identity = NOCpulse::SetID->new( user => 'nocpulse');
# Temporarily set credentials
$identity->su(); # Set IDs to $identity's IDs
# ... reduced-privilege code goes here
$identity->revert(); # Revert to credentials before su()
# Permanently set IDs to $identity (revert not possible)
$identity->su(permanent => 1);
DESCRIPTIONNOCpulse::SetID allows a process to change its credentials by setting
real and effective user and group IDs, supplemental group memberships,
and user-related environment variables ($HOME, $LOGNAME, $SHELL, $USER,
$USERNAME, and $PATH).
METHODSnew()
Create a new identity. Without arguments, new() takes all parameters
from the current environment. With a 'user' argument, new() takes
all parameters from the user's passwd and group entries. In either
case, you can override individual parameters. The full syntax is:
my $identity = new (
[user => $username,]
[ruid => $username_or_uid,]
[euid => $username_or_uid,]
[rgid => $groupname_or_gid,]
[egid => $groupname_or_gid,]
[groups => \@groupnames_or_gids,]
[env => \%env_hash,]
);
su()
Become the new identity. Without arguments, su() temporarily changes
to the new identity; the identity that was in effect when su() was
called can be restored by calling revert(). With the 'permanent'
argument set to a true value, su() will switch to the new identity
permanently, and revert() will generate a fatal error if called.
revert()
Switch back to the previous identity. When you call su(), the
function stores the current identity (real and effective UIDs and
GIDs, supplemental group memberships, and user-related environment
variables) in the object, unless the 'permanent' argument is
supplied. revert() switches back to the stored identity.
EXPORTS
None.
AUTHOR
Dave Faraldo <dfaraldo@redhat.com>
SEE ALSO
perl, perlvars, English
perl v5.14.0 2009-02-18 SetID(3)