pw_scan.c (52921) | pw_scan.c (53183) |
---|---|
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[] = | 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 52921 1999-11-06 20:21:04Z eivind $"; | 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 | 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 |
|
59int 60pw_scan(bp, pw) 61 char *bp; 62 struct passwd *pw; 63{ 64 long id; 65 int root; 66 char *p, *sh; --- 17 unchanged lines hidden (view full) --- 84 warnx("no uid for user %s", pw->pw_name); 85 return (0); 86 } 87 id = atol(p); 88 if (root && id) { 89 warnx("root uid should be 0"); 90 return (0); 91 } | 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 } |
92 if (id > USHRT_MAX) { 93 warnx("%s > max uid value (%d)", p, USHRT_MAX); | 99 if (pw_big_ids_warning && id > USHRT_MAX) { 100 warnx("%s > max uid value (%u)", p, USHRT_MAX); |
94 /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */ 95 } 96 pw->pw_uid = id; 97 98 if (!(p = strsep(&bp, ":"))) /* gid */ 99 goto fmt; 100 if(p[0]) pw->pw_fields |= _PWF_GID; 101 id = atol(p); | 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); |
102 if (id > USHRT_MAX) { 103 warnx("%s > max gid value (%d)", p, USHRT_MAX); | 109 if (pw_big_ids_warning && id > USHRT_MAX) { 110 warnx("%s > max gid value (%u)", p, USHRT_MAX); |
104 /* return (0); This should not be fatal! */ 105 } 106 pw->pw_gid = id; 107 108 pw->pw_class = strsep(&bp, ":"); /* class */ 109 if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS; 110 111 if (!(p = strsep(&bp, ":"))) /* change */ --- 38 unchanged lines hidden --- | 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 --- |