NAME

POSIX::1003::User - POSIX handling user and groups

SYNOPSIS

use POSIX::1003::User;

DESCRIPTION

FUNCTIONS

Standard POSIX

User and group management is provided via many functions, which are not portable either in implementation or in availability. See also http://www.cs.berkeley.edu/~daw/papers/setuid-usenix02.pdf

Get/set users

The implementation of setuid() differs per platform. seteuid() is more consistent and widely available. setresuid() is the most powerful, but not everywhere. Functions which are not implemented will return error ENOSYS.

. Example

my $uid = getuid();
defined $uid or die $!;

setuid($uid)
   or die "cannot set uid to $uid: $!\n";

my ($ruid, $euid, $suid) = getresuid;
defined $ruid or die $!;

setresuid($ruid, $euid, $suid)
   or die $!;
geteuid()
getresuid()
getuid()
seteuid($euid)
setresuid($ruid, $euid, $suid)

example:

# see also the set*uid examples above
my @mygroups = getgroups();
@mygroups or die $!;

setgroups(1,2,3) or die $!;
setreuid($ruid, $euid)
setuid($uid)

Get/set groups

The same use and limitations as the uid functions.

getegid()
getgid()
getgroups()

Returns a list of group-ids, which may (or may not) contain the effective group-id.

getresgid()
setegid($egid)
setgid($gid)
setregid($rgid, $egid)
setresgid($rgid, $egid, $sgid)

Information about users

getlogin()

The username associated with the controling terminal. Simply "getlogin" in perlfunc

getpwent()

Simply "getpwent" in perlfunc

getpwnam($username)

Simply "getpwnam" in perlfunc

getpwuid($userid)

Simply "getpwuid" in perlfunc

example:

my ($name, $passwd, $uid, $gid, $quota, $comment,
    $gcos, $dir, $shell, $expire) = getpwuid($uid);
my $uid  = getpwnam($username);
my $name = getpwuid($userid);

Information about groups

getgrent()

Simply "getgrent" in perlfunc

getgrgid($groupid)

Simply "getgrgid" in perlfunc

getgrnam($groupname)

Simply "getgrnam" in perlfunc

SEE ALSO

This module is part of POSIX-1003 distribution version 1.00, built on May 05, 2020. Website: http://perl.overmeer.net/CPAN. The code is based on POSIX, which is released with Perl itself. See also POSIX::Util for additional functionality.

COPYRIGHTS

Copyrights 2011-2020 on the perl code and the related documentation by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/