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 50644 1999-08-30 09:55:42Z 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 |
59static int big_uids = 0; /* Used for legacy max uid_t warning */ 60static int big_gids = 0; /* Used for legacy max gid_t warning */ 61 |
62int 63pw_scan(bp, pw) 64 char *bp; 65 struct passwd *pw; 66{ 67 long id; 68 int root; 69 char *p, *sh; --- 12 unchanged lines hidden (view full) --- 82 if (!(p = strsep(&bp, ":"))) /* uid */ 83 goto fmt; 84 if(p[0]) pw->pw_fields |= _PWF_UID; 85 id = atol(p); 86 if (root && id) { 87 warnx("root uid should be 0"); 88 return (0); 89 } |
90 if (id > USHRT_MAX && !(big_uids++)) { 91 warnx("%s > legacy max uid value (%d): " 92 "no more such warnings", p, USHRT_MAX); |
93 } 94 pw->pw_uid = id; 95 96 if (!(p = strsep(&bp, ":"))) /* gid */ 97 goto fmt; 98 if(p[0]) pw->pw_fields |= _PWF_GID; 99 id = atol(p); |
100 if (id > USHRT_MAX && !(big_gids++)) { 101 warnx("%s > max gid value (%d): " 102 "no more such warnings", p, USHRT_MAX); |
103 } 104 pw->pw_gid = id; 105 106 pw->pw_class = strsep(&bp, ":"); /* class */ 107 if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS; 108 109 if (!(p = strsep(&bp, ":"))) /* change */ 110 goto fmt; --- 37 unchanged lines hidden --- |