Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / man / man3 / User::pwent.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "User::pwent 3"
.TH User::pwent 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
.SH "NAME"
User::pwent \- by\-name interface to Perl's built\-in getpw*() functions
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 5
\& use User::pwent;
\& $pw = getpwnam('daemon') || die "No daemon user";
\& if ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?\ez#s ) {
\& print "gid 1 on root dir";
\& }
.Ve
.PP
.Vb 1
\& $real_shell = $pw->shell || '/bin/sh';
.Ve
.PP
.Vb 5
\& for (($fullname, $office, $workphone, $homephone) =
\& split /\es*,\es*/, $pw->gecos)
\& {
\& s/&/ucfirst(lc($pw->name))/ge;
\& }
.Ve
.PP
.Vb 5
\& use User::pwent qw(:FIELDS);
\& getpwnam('daemon') || die "No daemon user";
\& if ( $pw_uid == 1 && $pw_dir =~ m#^/(bin|tmp)?\ez#s ) {
\& print "gid 1 on root dir";
\& }
.Ve
.PP
.Vb 1
\& $pw = getpw($whoever);
.Ve
.PP
.Vb 4
\& use User::pwent qw/:DEFAULT pw_has/;
\& if (pw_has(qw[gecos expire quota])) { .... }
\& if (pw_has("name uid gid passwd")) { .... }
\& print "Your struct pwd has: ", scalar pw_has(), "\en";
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module's default exports override the core \fIgetpwent()\fR, \fIgetpwuid()\fR,
and \fIgetpwnam()\fR functions, replacing them with versions that return
\&\f(CW\*(C`User::pwent\*(C'\fR objects. This object has methods that return the
similarly named structure field name from the C's passwd structure
from \fIpwd.h\fR, stripped of their leading \*(L"pw_\*(R" parts, namely \f(CW\*(C`name\*(C'\fR,
\&\f(CW\*(C`passwd\*(C'\fR, \f(CW\*(C`uid\*(C'\fR, \f(CW\*(C`gid\*(C'\fR, \f(CW\*(C`change\*(C'\fR, \f(CW\*(C`age\*(C'\fR, \f(CW\*(C`quota\*(C'\fR, \f(CW\*(C`comment\*(C'\fR,
\&\f(CW\*(C`class\*(C'\fR, \f(CW\*(C`gecos\*(C'\fR, \f(CW\*(C`dir\*(C'\fR, \f(CW\*(C`shell\*(C'\fR, and \f(CW\*(C`expire\*(C'\fR. The \f(CW\*(C`passwd\*(C'\fR,
\&\f(CW\*(C`gecos\*(C'\fR, and \f(CW\*(C`shell\*(C'\fR fields are tainted when running in taint mode.
.PP
You may also import all the structure fields directly into your
namespace as regular variables using the :FIELDS import tag. (Note
that this still overrides your core functions.) Access these fields
as variables named with a preceding \f(CW\*(C`pw_\*(C'\fR in front their method
names. Thus, \f(CW\*(C`$passwd_obj\->shell\*(C'\fR corresponds to \f(CW$pw_shell\fR
if you import the fields.
.PP
The \fIgetpw()\fR function is a simple front-end that forwards
a numeric argument to \fIgetpwuid()\fR and the rest to \fIgetpwnam()\fR.
.PP
To access this functionality without the core overrides, pass the
\&\f(CW\*(C`use\*(C'\fR an empty import list, and then access function functions
with their full qualified names. The built-ins are always still
available via the \f(CW\*(C`CORE::\*(C'\fR pseudo\-package.
.Sh "System Specifics"
.IX Subsection "System Specifics"
Perl believes that no machine ever has more than one of \f(CW\*(C`change\*(C'\fR,
\&\f(CW\*(C`age\*(C'\fR, or \f(CW\*(C`quota\*(C'\fR implemented, nor more than one of either
\&\f(CW\*(C`comment\*(C'\fR or \f(CW\*(C`class\*(C'\fR. Some machines do not support \f(CW\*(C`expire\*(C'\fR,
\&\f(CW\*(C`gecos\*(C'\fR, or allegedly, \f(CW\*(C`passwd\*(C'\fR. You may call these methods
no matter what machine you're on, but they return \f(CW\*(C`undef\*(C'\fR if
unimplemented.
.PP
You may ask whether one of these was implemented on the system Perl
was built on by asking the importable \f(CW\*(C`pw_has\*(C'\fR function about them.
This function returns true if all parameters are supported fields
on the build platform, false if one or more were not, and raises
an exception if you asked about a field that Perl never knows how
to provide. Parameters may be in a space-separated string, or as
separate arguments. If you pass no parameters, the function returns
the list of \f(CW\*(C`struct pwd\*(C'\fR fields supported by your build platform's
C library, as a list in list context, or a space-separated string
in scalar context. Note that just because your C library had
a field doesn't necessarily mean that it's fully implemented on
that system.
.PP
Interpretation of the \f(CW\*(C`gecos\*(C'\fR field varies between systems, but
traditionally holds 4 comma-separated fields containing the user's
full name, office location, work phone number, and home phone number.
An \f(CW\*(C`&\*(C'\fR in the gecos field should be replaced by the user's properly
capitalized login \f(CW\*(C`name\*(C'\fR. The \f(CW\*(C`shell\*(C'\fR field, if blank, must be
assumed to be \fI/bin/sh\fR. Perl does not do this for you. The
\&\f(CW\*(C`passwd\*(C'\fR is one-way hashed garble, not clear text, and may not be
unhashed save by brute-force guessing. Secure systems use more a
more secure hashing than \s-1DES\s0. On systems supporting shadow password
systems, Perl automatically returns the shadow password entry when
called by a suitably empowered user, even if your underlying
vendor-provided C library was too short-sighted to realize it should
do this.
.PP
See \fIpasswd\fR\|(5) and \fIgetpwent\fR\|(3) for details.
.SH "NOTE"
.IX Header "NOTE"
While this class is currently implemented using the Class::Struct
module to build a struct-like class, you shouldn't rely upon this.
.SH "AUTHOR"
.IX Header "AUTHOR"
Tom Christiansen
.SH "HISTORY"
.IX Header "HISTORY"
.IP "March 18th, 2000" 4
.IX Item "March 18th, 2000"
Reworked internals to support better interface to dodgey fields
than normal Perl function provides. Added \fIpw_has()\fR field. Improved
documentation.