Deleted Added
sdiff udiff text old ( 52921 ) new ( 53183 )
full compact
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/lib/libc/gen/pw_scan.c 53183 1999-11-15 16:45:37Z sheldonh $";
40#endif /* not lint */
41
42/*
43 * This module is used to "verify" password entries by chpass(1) and
44 * pwd_mkdb(8).
45 */
46
47#include <sys/param.h>
48
49#include <err.h>
50#include <fcntl.h>
51#include <pwd.h>
52#include <stdio.h>
53#include <string.h>
54#include <stdlib.h>
55#include <unistd.h>
56
57#include "pw_scan.h"
58
59/*
60 * Some software assumes that IDs are short. We should emit warnings
61 * for id's which can not be stored in a short, but we are more liberal
62 * by default, warning for IDs greater than USHRT_MAX.
63 */
64int pw_big_ids_warning = 1;
65
66int
67pw_scan(bp, pw)
68 char *bp;
69 struct passwd *pw;
70{
71 long id;
72 int root;
73 char *p, *sh;

--- 17 unchanged lines hidden (view full) ---

91 warnx("no uid for user %s", pw->pw_name);
92 return (0);
93 }
94 id = atol(p);
95 if (root && id) {
96 warnx("root uid should be 0");
97 return (0);
98 }
99 if (pw_big_ids_warning && id > USHRT_MAX) {
100 warnx("%s > max uid value (%u)", p, USHRT_MAX);
101 /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
102 }
103 pw->pw_uid = id;
104
105 if (!(p = strsep(&bp, ":"))) /* gid */
106 goto fmt;
107 if(p[0]) pw->pw_fields |= _PWF_GID;
108 id = atol(p);
109 if (pw_big_ids_warning && id > USHRT_MAX) {
110 warnx("%s > max gid value (%u)", p, USHRT_MAX);
111 /* return (0); This should not be fatal! */
112 }
113 pw->pw_gid = id;
114
115 pw->pw_class = strsep(&bp, ":"); /* class */
116 if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS;
117
118 if (!(p = strsep(&bp, ":"))) /* change */

--- 38 unchanged lines hidden ---