📄 user::pwent.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" 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. \*(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-.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\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" 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..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" 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 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.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(\*(Aqdaemon\*(Aq) || die "No daemon user";\& if ( $pw\->uid == 1 && $pw\->dir =~ m#^/(bin|tmp)?\ez#s ) {\& print "gid 1 on root dir";\& }\&\& $real_shell = $pw\->shell || \*(Aq/bin/sh\*(Aq;\&\& for (($fullname, $office, $workphone, $homephone) =\& split /\es*,\es*/, $pw\->gecos)\& {\& s/&/ucfirst(lc($pw\->name))/ge;\& }\&\& use User::pwent qw(:FIELDS);\& getpwnam(\*(Aqdaemon\*(Aq) || die "No daemon user";\& if ( $pw_uid == 1 && $pw_dir =~ m#^/(bin|tmp)?\ez#s ) {\& print "gid 1 on root dir";\& }\&\& $pw = getpw($whoever);\&\& 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 thesimilarly named structure field name from the C's passwd structurefrom \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..PPYou may also import all the structure fields directly into yournamespace as regular variables using the :FIELDS import tag. (Notethat this still overrides your core functions.) Access these fieldsas variables named with a preceding \f(CW\*(C`pw_\*(C'\fR in front their methodnames. Thus, \f(CW\*(C`$passwd_obj\->shell\*(C'\fR corresponds to \f(CW$pw_shell\fRif you import the fields..PPThe \fIgetpw()\fR function is a simple front-end that forwardsa numeric argument to \fIgetpwuid()\fR and the rest to \fIgetpwnam()\fR..PPTo access this functionality without the core overrides, pass the\&\f(CW\*(C`use\*(C'\fR an empty import list, and then access function functionswith their full qualified names. The built-ins are always stillavailable 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 methodsno matter what machine you're on, but they return \f(CW\*(C`undef\*(C'\fR ifunimplemented..PPYou may ask whether one of these was implemented on the system Perlwas 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 fieldson the build platform, false if one or more were not, and raisesan exception if you asked about a field that Perl never knows howto provide. Parameters may be in a space-separated string, or asseparate arguments. If you pass no parameters, the function returnsthe list of \f(CW\*(C`struct pwd\*(C'\fR fields supported by your build platform'sC library, as a list in list context, or a space-separated stringin scalar context. Note that just because your C library hada field doesn't necessarily mean that it's fully implemented onthat system..PPInterpretation of the \f(CW\*(C`gecos\*(C'\fR field varies between systems, buttraditionally holds 4 comma-separated fields containing the user'sfull 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 properlycapitalized login \f(CW\*(C`name\*(C'\fR. The \f(CW\*(C`shell\*(C'\fR field, if blank, must beassumed 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 beunhashed save by brute-force guessing. Secure systems use more amore secure hashing than \s-1DES\s0. On systems supporting shadow passwordsystems, Perl automatically returns the shadow password entry whencalled by a suitably empowered user, even if your underlyingvendor-provided C library was too short-sighted to realize it shoulddo this..PPSee \fIpasswd\fR\|(5) and \fIgetpwent\fR\|(3) for details..SH "NOTE".IX Header "NOTE"While this class is currently implemented using the Class::Structmodule 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 fieldsthan normal Perl function provides. Added \fIpw_has()\fR field. Improveddocumentation.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -