summaryrefslogtreecommitdiff
path: root/man/zh_CN/man3/shadow.3
blob: e01c99ae8384639d76ed677f4307bcf0f5c91370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
'\" t
.\"     Title: shadow
.\"    Author: Julianne Frances Haugh
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 2014-05-09
.\"    Manual: 库函数调用
.\"    Source: shadow-utils 4.2
.\"  Language: Chinese Simplified
.\"
.TH "SHADOW" "3" "2014-05-09" "shadow\-utils 4\&.2" "库函数调用"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "名称"
shadow, getspnam \- 加密密码文件工具函数
.SH "SYNTAX"
.PP
\fI#include <shadow\&.h>\fR
.PP
\fIstruct spwd *getspent();\fR
.PP
\fIstruct spwd *getspnam(char\fR\fI*name\fR\fI);\fR
.PP
\fIvoid setspent();\fR
.PP
\fIvoid endspent();\fR
.PP
\fIstruct spwd *fgetspent(FILE\fR\fI*fp\fR\fI);\fR
.PP
\fIstruct spwd *sgetspent(char\fR\fI*cp\fR\fI);\fR
.PP
\fIint putspent(struct spwd\fR\fI*p,\fR\fIFILE\fR\fI*fp\fR\fI);\fR
.PP
\fIint lckpwdf();\fR
.PP
\fIint ulckpwdf();\fR
.SH "描述"
.PP
\fIshadow\fR
处理 shadow 密码文件
/etc/shadow
的内容。\fI#include\fR
文件中的结构是:
.sp
.if n \{\
.RS 4
.\}
.nf
struct spwd {
      char		*sp_namp; /* user login name */
      char		*sp_pwdp; /* encrypted password */
      long int		sp_lstchg; /* last password change */
      long int		sp_min; /* days until change allowed\&. */
      long int		sp_max; /* days before change required */
      long int		sp_warn; /* days warning for expiration */
      long int		sp_inact; /* days before account inactive */
      long int		sp_expire; /* date when account expires */
      unsigned long int	sp_flag; /* reserved for future use */
}
    
.fi
.if n \{\
.RE
.\}
.PP
每个字段的含义是:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_namp \- 指向以 null 结束的用户名的指针
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_pwdp \- 指向 null 结束的密码的指针
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_lstchg \- 最近更改密码的日期(日期计算方法是从1970年1月1日开始的天数)
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_min \- days before which password may not be changed
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_max \- days after which password must be changed
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_warn \- days before password is to expire that user is warned of pending password expiration
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_inact \- days after password expires that account is considered inactive and disabled
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_expire \- days since Jan 1, 1970 when account will be disabled
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
sp_flag \- reserved for future use
.RE
.SH "描述"
.PP
\fIgetspent\fR,
\fIgetspname\fR,
\fIfgetspent\fR, and
\fIsgetspent\fR
each return a pointer to a
\fIstruct spwd\fR\&.
\fIgetspent\fR
returns the next entry from the file, and
\fIfgetspent\fR
returns the next entry from the given stream, which is assumed to be a file of the proper format\&.
\fIsgetspent\fR
returns a pointer to a
\fIstruct spwd\fR
using the provided string as input\&.
\fIgetspnam\fR
searches from the current position in the file for an entry matching
\fIname\fR\&.
.PP
\fIsetspent\fR
和
\fIendspent\fR
分别用来开始和结束对影子密码文件的访问。
.PP
需要使用
\fIlckpwdf\fR
和
\fIulckpwdf\fR
函数来确保对
/etc/shadow
文件的互斥访问。\fIlckpwdf\fR
使用
\fIpw_lock\fR
来获取一个最长为 15 秒的锁,然后继续使用
\fIspw_lock\fR
来获取长度为开始的 15 秒时间的剩余量的第二把锁。总计 15 秒之后,无论哪个失败,\fIlckpwdf\fR
都返回 \-1。两把锁都获取成功时,返回 0。
.SH "DIAGNOSTICS"
.PP
如果没有更多条目了或者处理时出错,此函数返回 NULL。使用
\fIint\fR
类型返回值的函数返回 0 表示成功,\-1 表示失败。
.SH "CAVEATS"
.PP
这些函数只能由超级用户使用,因为对影子密码文件的访问是受限的。
.SH "文件"
.PP
/etc/shadow
.RS 4
安全用户账户信息。
.RE
.SH "参见"
.PP
\fBgetpwent\fR(3),
\fBshadow\fR(5)\&.