2
* Copyright 1989 - 1994, Julianne Frances Haugh
2
* Copyright (c) 1989 - 1994, Julianne Frances Haugh
3
* Copyright (c) 1996 - 1998, Marek Michałkiewicz
4
* Copyright (c) 2003 - 2005, Tomasz Kłoczko
5
* Copyright (c) 2009 , Nicolas François
3
6
* All rights reserved.
5
8
* Redistribution and use in source and binary forms, with or without
10
13
* 2. Redistributions in binary form must reproduce the above copyright
11
14
* notice, this list of conditions and the following disclaimer in the
12
15
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
* 3. The name of the copyright holders or contributors may not be used to
17
* endorse or promote products derived from this software without
18
* specific prior written permission.
17
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
33
#include <config.h>
179
183
* incorrectly formatted number, unless we are using NIS.
182
spwd.sp_lstchg = strtol (fields[2], &cpp, 10);
183
if ((spwd.sp_lstchg == 0) && *cpp) {
192
} else if (fields[2][0] == '\0')
186
if (fields[2][0] == '\0') {
193
187
spwd.sp_lstchg = -1;
189
if (getlong (fields[2], &spwd.sp_lstchg) == 0) {
196
} else if (spwd.sp_lstchg < 0) {
196
202
* Get the minimum period between password changes.
199
spwd.sp_min = strtol (fields[3], &cpp, 10);
200
if ((spwd.sp_min == 0) && *cpp) {
209
} else if (fields[3][0] == '\0')
205
if (fields[3][0] == '\0') {
210
206
spwd.sp_min = -1;
208
if (getlong (fields[3], &spwd.sp_min) == 0) {
215
} else if (spwd.sp_min < 0) {
213
221
* Get the maximum number of days a password is valid.
216
spwd.sp_max = strtol (fields[4], &cpp, 10);
217
if ((spwd.sp_max == 0) && *cpp) {
226
} else if (fields[4][0] == '\0')
224
if (fields[4][0] == '\0') {
227
225
spwd.sp_max = -1;
227
if (getlong (fields[4], &spwd.sp_max) == 0) {
234
} else if (spwd.sp_max < 0) {
230
240
* If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow
242
254
* Get the number of days of password expiry warning.
245
spwd.sp_warn = strtol (fields[5], &cpp, 10);
246
if ((spwd.sp_warn == 0) && *cpp) {
255
} else if (fields[5][0] == '\0')
257
if (fields[5][0] == '\0') {
256
258
spwd.sp_warn = -1;
260
if (getlong (fields[5], &spwd.sp_warn) == 0) {
267
} else if (spwd.sp_warn < 0) {
259
273
* Get the number of days of inactivity before an account is
263
spwd.sp_inact = strtol (fields[6], &cpp, 10);
264
if ((spwd.sp_inact == 0) && *cpp) {
273
} else if (fields[6][0] == '\0')
277
if (fields[6][0] == '\0') {
274
278
spwd.sp_inact = -1;
280
if (getlong (fields[6], &spwd.sp_inact) == 0) {
287
} else if (spwd.sp_inact < 0) {
277
293
* Get the number of days after the epoch before the account is
281
spwd.sp_expire = strtol (fields[7], &cpp, 10);
282
if ((spwd.sp_expire == 0) && *cpp) {
297
if (fields[7][0] == '\0') {
300
if (getlong (fields[7], &spwd.sp_expire) == 0) {
307
} else if (spwd.sp_expire < 0) {
291
} else if (fields[7][0] == '\0')
295
313
* This field is reserved for future use. But it isn't supposed
296
314
* to have anything other than a valid integer in it.
299
spwd.sp_flag = strtol (fields[8], &cpp, 10);
300
if ((spwd.sp_flag == 0) && *cpp) {
317
if (fields[8][0] == '\0') {
318
spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
320
if (getlong (fields[8], &spwd.sp_flag) == 0) {
321
/* FIXME: add a getulong function */
324
spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
328
} else if (spwd.sp_flag < 0) {
309
} else if (fields[8][0] == '\0')
321
342
char buf[BUFSIZ];
328
while (fgets (buf, sizeof buf, fp) != (char *) 0)
350
while (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
330
if (fgets (buf, sizeof buf, fp) != (char *) 0)
352
if (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
333
355
cp = strchr (buf, '\n');
337
if (nis_ignore && IS_NISCHAR (buf[0]))
360
if (nis_ignore && IS_NISCHAR (buf[0])) {
340
364
return my_sgetspent (buf);