Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "User::pwent 3" | |
132 | .TH User::pwent 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | User::pwent \- by\-name interface to Perl's built\-in getpw*() functions | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 5 | |
138 | \& use User::pwent; | |
139 | \& $pw = getpwnam('daemon') || die "No daemon user"; | |
140 | \& if ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?\ez#s ) { | |
141 | \& print "gid 1 on root dir"; | |
142 | \& } | |
143 | .Ve | |
144 | .PP | |
145 | .Vb 1 | |
146 | \& $real_shell = $pw->shell || '/bin/sh'; | |
147 | .Ve | |
148 | .PP | |
149 | .Vb 5 | |
150 | \& for (($fullname, $office, $workphone, $homephone) = | |
151 | \& split /\es*,\es*/, $pw->gecos) | |
152 | \& { | |
153 | \& s/&/ucfirst(lc($pw->name))/ge; | |
154 | \& } | |
155 | .Ve | |
156 | .PP | |
157 | .Vb 5 | |
158 | \& use User::pwent qw(:FIELDS); | |
159 | \& getpwnam('daemon') || die "No daemon user"; | |
160 | \& if ( $pw_uid == 1 && $pw_dir =~ m#^/(bin|tmp)?\ez#s ) { | |
161 | \& print "gid 1 on root dir"; | |
162 | \& } | |
163 | .Ve | |
164 | .PP | |
165 | .Vb 1 | |
166 | \& $pw = getpw($whoever); | |
167 | .Ve | |
168 | .PP | |
169 | .Vb 4 | |
170 | \& use User::pwent qw/:DEFAULT pw_has/; | |
171 | \& if (pw_has(qw[gecos expire quota])) { .... } | |
172 | \& if (pw_has("name uid gid passwd")) { .... } | |
173 | \& print "Your struct pwd has: ", scalar pw_has(), "\en"; | |
174 | .Ve | |
175 | .SH "DESCRIPTION" | |
176 | .IX Header "DESCRIPTION" | |
177 | This module's default exports override the core \fIgetpwent()\fR, \fIgetpwuid()\fR, | |
178 | and \fIgetpwnam()\fR functions, replacing them with versions that return | |
179 | \&\f(CW\*(C`User::pwent\*(C'\fR objects. This object has methods that return the | |
180 | similarly named structure field name from the C's passwd structure | |
181 | from \fIpwd.h\fR, stripped of their leading \*(L"pw_\*(R" parts, namely \f(CW\*(C`name\*(C'\fR, | |
182 | \&\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, | |
183 | \&\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, | |
184 | \&\f(CW\*(C`gecos\*(C'\fR, and \f(CW\*(C`shell\*(C'\fR fields are tainted when running in taint mode. | |
185 | .PP | |
186 | You may also import all the structure fields directly into your | |
187 | namespace as regular variables using the :FIELDS import tag. (Note | |
188 | that this still overrides your core functions.) Access these fields | |
189 | as variables named with a preceding \f(CW\*(C`pw_\*(C'\fR in front their method | |
190 | names. Thus, \f(CW\*(C`$passwd_obj\->shell\*(C'\fR corresponds to \f(CW$pw_shell\fR | |
191 | if you import the fields. | |
192 | .PP | |
193 | The \fIgetpw()\fR function is a simple front-end that forwards | |
194 | a numeric argument to \fIgetpwuid()\fR and the rest to \fIgetpwnam()\fR. | |
195 | .PP | |
196 | To access this functionality without the core overrides, pass the | |
197 | \&\f(CW\*(C`use\*(C'\fR an empty import list, and then access function functions | |
198 | with their full qualified names. The built-ins are always still | |
199 | available via the \f(CW\*(C`CORE::\*(C'\fR pseudo\-package. | |
200 | .Sh "System Specifics" | |
201 | .IX Subsection "System Specifics" | |
202 | Perl believes that no machine ever has more than one of \f(CW\*(C`change\*(C'\fR, | |
203 | \&\f(CW\*(C`age\*(C'\fR, or \f(CW\*(C`quota\*(C'\fR implemented, nor more than one of either | |
204 | \&\f(CW\*(C`comment\*(C'\fR or \f(CW\*(C`class\*(C'\fR. Some machines do not support \f(CW\*(C`expire\*(C'\fR, | |
205 | \&\f(CW\*(C`gecos\*(C'\fR, or allegedly, \f(CW\*(C`passwd\*(C'\fR. You may call these methods | |
206 | no matter what machine you're on, but they return \f(CW\*(C`undef\*(C'\fR if | |
207 | unimplemented. | |
208 | .PP | |
209 | You may ask whether one of these was implemented on the system Perl | |
210 | was built on by asking the importable \f(CW\*(C`pw_has\*(C'\fR function about them. | |
211 | This function returns true if all parameters are supported fields | |
212 | on the build platform, false if one or more were not, and raises | |
213 | an exception if you asked about a field that Perl never knows how | |
214 | to provide. Parameters may be in a space-separated string, or as | |
215 | separate arguments. If you pass no parameters, the function returns | |
216 | the list of \f(CW\*(C`struct pwd\*(C'\fR fields supported by your build platform's | |
217 | C library, as a list in list context, or a space-separated string | |
218 | in scalar context. Note that just because your C library had | |
219 | a field doesn't necessarily mean that it's fully implemented on | |
220 | that system. | |
221 | .PP | |
222 | Interpretation of the \f(CW\*(C`gecos\*(C'\fR field varies between systems, but | |
223 | traditionally holds 4 comma-separated fields containing the user's | |
224 | full name, office location, work phone number, and home phone number. | |
225 | An \f(CW\*(C`&\*(C'\fR in the gecos field should be replaced by the user's properly | |
226 | capitalized login \f(CW\*(C`name\*(C'\fR. The \f(CW\*(C`shell\*(C'\fR field, if blank, must be | |
227 | assumed to be \fI/bin/sh\fR. Perl does not do this for you. The | |
228 | \&\f(CW\*(C`passwd\*(C'\fR is one-way hashed garble, not clear text, and may not be | |
229 | unhashed save by brute-force guessing. Secure systems use more a | |
230 | more secure hashing than \s-1DES\s0. On systems supporting shadow password | |
231 | systems, Perl automatically returns the shadow password entry when | |
232 | called by a suitably empowered user, even if your underlying | |
233 | vendor-provided C library was too short-sighted to realize it should | |
234 | do this. | |
235 | .PP | |
236 | See \fIpasswd\fR\|(5) and \fIgetpwent\fR\|(3) for details. | |
237 | .SH "NOTE" | |
238 | .IX Header "NOTE" | |
239 | While this class is currently implemented using the Class::Struct | |
240 | module to build a struct-like class, you shouldn't rely upon this. | |
241 | .SH "AUTHOR" | |
242 | .IX Header "AUTHOR" | |
243 | Tom Christiansen | |
244 | .SH "HISTORY" | |
245 | .IX Header "HISTORY" | |
246 | .IP "March 18th, 2000" 4 | |
247 | .IX Item "March 18th, 2000" | |
248 | Reworked internals to support better interface to dodgey fields | |
249 | than normal Perl function provides. Added \fIpw_has()\fR field. Improved | |
250 | documentation. |